Skip to content

[7.0.1]Bug: cy.intercept POST terminates cypress process #15901

@njh7799

Description

@njh7799

Simplified reproduction

https://github.com/bahmutov/cypress-15901-bug

Current behavior

presettings

  • The code includes POST request with Chineese words inside it's body (Chineese words should be long enough)
<script>
    fetch('http://localhost:5000/api/sample', {
    method: 'POST', body: JSON.stringify({first: '東京都新東', second: '東京都新'})})
</script>
  • use cy.intercept in the test with the API above
cy.intercept('POST', 'http://localhost:5000/api/sample');

Result

If I run Cypress, it's process is terminated with error messages
cypress-intercept-bug

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (123)
    at write_ (_http_outgoing.js:696:11)
    at ClientRequest.write (_http_outgoing.js:661:15)
    at Request.write (/Users/user/Library/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
    at /Users/user/Library/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
    at Array.forEach (<anonymous>:null:null)
    at end (/Users/user/Library/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
    at Immediate._onImmediate (/Users/user/Library/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
    at processImmediate (internal/timers.js:461:21)
 {
  code: 'ERR_INVALID_ARG_TYPE'
}

image

Desired behavior

Cypress test process must not be terminated.

Test code to reproduce

https://github.com/njh7799/cypress7.0-intercept-post-bug

Versions

Cypress version: 7.0.1
OS: MAC Big Sir

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions