-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to read the 'responseXML' property from 'XMLHttpRequest', responseType
was 'text'
#6630
Comments
The example from the website works for a standard XHR request and should work in your case, so there's something amiss. The test below works for example. it('route status', () => {
cy.visit('https://example.cypress.io/commands/network-requests')
cy.server()
cy.route('GET', 'comments/*').as('getComment')
cy.get('.network-btn').click()
cy.wait('@getComment').its('status').should('eq', 200)
}) It appears it's saying the
|
responseType
was 'text'
For my purposes, the example you gave me solves my problem, so I got what I needed out of this issue report. I recommend you include both examples in your documentation. Thanks for the help! |
Hello I had the same issue when upgrading cypress from 3.6.0 to 4.1.0. Failing code was cy.wait('@alias')
.should('have.property', 'status', 200);
lead to the same error on response type. Changing my code to : cy.wait('@alias)
.its('status')
.should('eq', 200) fixed the issue |
Interesting, so it sounds like it might be a bug in the behavior of I like the new syntax better anyway, so I'm going to switch to it. But it seems like both syntaxes should work. |
FWIW, I ran into this issue as well. The offending line was: cy.get('@alias').should('have.length', 1) Changing it to this solved the problem: cy.get('@alias').its('length').should('eq', 1) |
I can't reproduce this in Cypress 4.3.0. I imagine it has something specific to do with the requested url. it('route status', () => {
cy.visit('https://example.cypress.io/commands/network-requests')
cy.server()
cy.route('GET', 'comments/*').as('getComment')
cy.get('.network-btn').click()
cy.wait('@getComment').should('have.property', 'status', 200)
}) Can someone provide a route to be used here that can reproduce this? The stack trace mentions the |
@jennifer-shehane I just reproduced it again on our app, but I'm running it locally and can't give you access to our public endpoints. Do these headers help?
|
I'm getting the same error, except that the responseType is blob. I don't care about the response content. I just want to check if the request has been made or not, but using should directly fails because it tries to resolve the response value. Using the |
I'm getting the same error, in my case, we must modify the code in order to run the test cases that work before Cypress version 4. @jennifer-shehane the code below can help to reproduce the error. My alias definition: cy.server()
cy.route('POST', '**/api/user').as('user') Original code (works in Cypress 3): cy.wait('@user').then(xhr => {
expect(xhr).to.have.property('status').to.equal(201)
expect(xhr.response.body).to.have.property('prop1')
return xhr.response.body.id
}) But if upgrade to Cypress 4, we must use "Destructuring Assignment" if we want to get working our test just as before: cy.wait('@user').then(({ status, response }) => {
expect(status).to.equal(201)
expect(response.body).to.have.property('prop1')
return response.body.id
}) But, Why? I don't see any breaking change on CHANGELOG. I have Cypress@4.7.0. |
This made my life easier: Cypress.Commands.add(
'withStatus',
{
prevSubject: true,
},
(subject, status) => {
return cy.wrap(subject).its('status').should('eq', status);
},
); Used like: |
Still getting this issue in 4.12.1. Using @jennifer-shehane 's alternative as cited above, works and it is just as readable. |
Can I recommend:
This works for both a single value or an array of values. Used like: |
This blog post still shows the old way to check a response status.
instead of
I understand it might still be correct for the version that was out at the time the post was published. However, people (like me) using the latest version will stumble upon that post will encounter the error. |
|
Example from docs produces error.
From https://docs.cypress.io/guides/guides/network-requests.html#Assertions
In my example, I used:
Produces the following error:
The following example works:
Desired behavior:
Would like the example from the documents to work.
Preferably, I'd like
cy.wait(...)
to fail by default if a 200 isn't returned, or to have a really easy way of adding our preferred status code to return. Something likecy.wait('@create', 201)
.Versions
4.0.1
The text was updated successfully, but these errors were encountered: