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
Response is modified by cypress #2599
Comments
@FlorianM93 Could you be more specific about what modifications are done to responses that is causing issues? |
The pasted code above is the response I got from a GET in my application. So the cypress runner somehow wraps the html-document into that response. |
Could you paste your test code (omitting sensitive urls if needed)? Also, the request headers / response headers of the request that's doing this? |
The failing code (there is a comment, where my applicaiton crashes) describe('Test Fail', () => {
before(() => {
cy.visit('#dashboard').then(() => {
cy.get('.x-window', {timeout: 25000}).contains('Login').should('be.visible');
cy.get('.x-panel').within(() => {
cy.get('input:first').type('user');
cy.get('input:last').type('password');
cy.get('.x-btn').click();
});
// after login, the first request (login successful) from my main application fails
cy.get('.main-header-logo', {timeout: 25000}).should('be.visible');
});
});
it.only('should upload the test data', () => {
cy.title().should('be', 'Page Title');
});
}); Request Headers:
Response Headers:
|
I see you posted the request headers for a I wish something were standing out more in the information you provided as the obvious problem, but we'll likely need a reproducible repo to get debugging started on this. As a side note, you should not need the |
Ah right, it's a POST not a GET request. Thanks for the note with the visit and then. |
Sadly I have no public repo to publish for you :( Maybe I can try to build an example later |
I figured out that it looks like a timing issue. My app only crashed for a producation build, which has minified JS. When I use a non minified build, then cypress runs normally. So it looks like my app loads 'to fast' so that cypress is not correctly setted up? |
Hello again... Ok this issue seems to be partially a cypress (injecting the cypress code into received request data) and partially an application issue (using Cypress doesn't properly work with web applications that use an If you run the app with a cleared Now if there's some XHR response with One would expect cypress to inject itself always into the visited application's Attached there's an example app and test spec to exhibit the behavior, described here. |
That’s really interesting information, good debugging
…Sent from my iPhone
On Oct 17, 2018, at 08:01, Florian Macherey ***@***.***> wrote:
Hello again...
Ok this issue seems to be partially a cypress (injecting the cypress code into received request data) and partially an application issue (using appcache and setting content-type text/html on json).
Cypress doesn't properly work with web applications that use an appcache. Cypress fails to insert the __cypress.initial=true cookie due to the index page being cached in the appcache.
If you run the app with a cleared appcache, the index.html is correctly loaded and the cypress-loader properly injected. On the second run the index.html is used from the cache, where cypress fails to add the __cypress.initial cookie and thus delaying it to the first response with content-type text/html to a request with the __cypress.initial cookie (in our example it was the returned json).
Now if there's some XHR response with content-type text/html and the __cypress.initial, cypress injects it's loader code, regardless of it being a dynamically loaded HTML-snippet. This might probably result in event/action 'app:window:before:load' triggering multiple times.
One would expect cypress to inject itself always into the visited application's index file and not into subsequent XHR-responses, potentially altering behavior.
Attached there's an example app and test spec to exhibit the behavior, described here.
dist.tar.gz
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@bahmutov @jennifer-shehane do you have any progress or time here, when this might get fixed? :) |
Facing the same issue. Would be great if it gets fixed soon. This bug doesn't necessarily stop me from testing my app further (atleast for now), but still should be fixed. |
Thanks for narrowing this issue down for us. Would it be correct to say that things would work well for your use case if Cypress were to clear |
Not fully. The problem is, for the second (and all other) run of the tests, the index.html is cached by browser. So cypress doesn’t plug in there but into the next “file” which here is an XHR response. |
Testing with the 6.4.0 version, when download CSV with click, the file injected with header. <script type='text/javascript'> document.domain = 'XXXXXXXXXX'; var Cypress = window.Cypress = parent.Cypress; if (!Cypress) { throw new Error('Something went terribly wrong and we cannot proceed. We expected to find the global Cypress in the parent window but it is missing!. This should never happen and likely is a bug. Please open an issue!'); }; Cypress.action('app:window:before:load', window); </script>Response Header |
@chincheeheng This is expected behavior. We have to inject this to run Cypress. Since this issue hasn't had activity in a while, we'll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we'd be happy to reopen. |
This will be a problem when we try to run download, when the thing injected to csv file, then the validation will not work. |
@chincheeheng Can you provide a basic example in a newly opened issue? HTML + cypress code where your validation is failing? Thanks! |
cypress ainda tem esse problema retorna o download CSV com o HTML <script type='text/javascript'> document.domain = ..... |
Sometimes cypress seems to modify the responses from my server. This happens if I use a (virtual) host to simulate an other server than localhost. After the html output is the expected output from my request (the json part at the end).
The text was updated successfully, but these errors were encountered: