Closed lianzhao closed 3 years ago
Hey @lianzhao, we have a fix going out in our next release on Monday for the ERR_INVALID_ARG_TYPE error here: https://github.com/cypress-io/cypress/issues/16223 You can download the pre-release version of Cypress to get this fix. Follow the instructions here
I can't determine if your issue is already fixed by this as there's no enough info provided to reproduce it.
Can you try the fix above and verify/close the issue if fixed? Otherwise can you provide a full reproducible example? I tried to recreate the issue with the body provided, but Cypress does not error in my example below.
Thanks!
it('test cy.intercept()', () => {
cy.intercept('/users').as('postUrl')
cy.visit('https://example.com')
cy.window().then((win) => {
const xhr = new win.XMLHttpRequest()
xhr.open('POST', '/users')
xhr.send({
"SearchType": 2,
"Keywords": "冀B9QG30",
"RealNamed": 0,
"Images": [],
"Tags": [],
"TopX": 100,
"Limit": 100,
"Offset": 0
})
})
cy.wait('@postUrl')
})
@jennifer-shehane Sorry for the late reply, here's my code to reproduce:
it('test cy.intercept()', () => {
cy.intercept('POST', '/users').as('postUrl');
cy.visit('https://example.com');
cy.window().then(win => {
fetch('/users', {
headers: {
accept: 'application/json',
'accept-language': 'en-US,en;q=0.9,ja;q=0.8',
authorization:
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjEwNjkyNDgsImlkIjoiOWIyNmIwMTctZjFkNy00Mjk4LWFmMjYtODRhOTI0NjY2NGYyIiwib3JpZ19pYXQiOjE2MjAzNTEwODZ9.YKjKVpA_Y8fvTwrmhTh5EwjuW5eITM4e2r7ZXWtdrZQ',
'content-type': 'application/json',
pragma: 'no-cache',
},
referrer: 'http://192.168.2.159/',
referrerPolicy: 'strict-origin-when-cross-origin',
body:
'{"SearchType":2,"Keywords":"冀B9QG30","RealNamed":0,"Images":[],"Tags":[],"TopX":100,"Limit":100,"Offset":0}',
method: 'POST',
mode: 'cors',
credentials: 'include',
});
});
cy.wait('@postUrl');
});
And here's my cypress config
{
animationDistanceThreshold:5
baseUrl:"http://localhost:8080/"
blockHosts:null
browsers:Chrome, Chromium, Canary, Firefox, Edge, Edge Canary, Electron
chromeWebSecurity:true
component:[object Object]
componentFolder:"cypress/component"
defaultCommandTimeout:4000
downloadsFolder:"tests/e2e/downloads"
e2e:[object Object]
env:codeCoverageTasksRegistered
execTimeout:60000
experimentalFetchPolyfill:false
experimentalInteractiveRunEvents:false
experimentalSourceRewriting:false
experimentalStudio:false
fileServerFolder:""
firefoxGcInterval:runMode, openMode
fixturesFolder:"tests/e2e/fixtures"
hosts:null
ignoreTestFiles:"**/_utils/*"
includeShadowDom:false
integrationFolder:"tests/e2e/specs"
modifyObstructiveCode:true
nodeVersion:"default"
numTestsKeptInMemory:5
pageLoadTimeout:60000
pluginsFile:"tests/e2e/plugins/index.js"
port:null
projectId:null
redirectionLimit:20
reporter:"mochawesome"
reporterOptions:overwrite, html, json
requestTimeout:5000
responseTimeout:30000
retries:runMode, openMode
screenshotOnRunFailure:true
screenshotsFolder:"tests/e2e/screenshots"
supportFile:"tests/e2e/support/index.js"
taskTimeout:60000
testFiles:"**/*.*"
trashAssetsBeforeRuns:true
userAgent:null
video:false
videoCompression:32
videosFolder:"tests/e2e/videos"
videoUploadOnPasses:true
viewportHeight:900
viewportWidth:1600
waitForAnimations:true
scrollBehavior:"top"
watchForFileChanges:true
configFile:"/Users/lianzhao/work/src/github.com/deepglint/jormougand/cypress.json"
version:"7.2.0"
testingType:"e2e"
}
BTW, cypress won't crash if you remove the Chinese character 冀
from the code above.
Thank you for your help!
@lianzhao you can try pre-release version 7.3.0
npm install https://cdn.cypress.io/beta/npm/7.3.0/circle-develop-5c453115334e290af66b3594a19e4e455cfa7596/cypress.tgz
cypress@7.3.0
fixed this issue, close.
Current behavior
Cypress crashes when I use
cy.intercept
to intercept a POST request with bodyDesired behavior
Cypress wont crash.
Test code to reproduce
I think it's the same issue with https://github.com/cypress-io/cypress/issues/15901 ?
Versions