Skip to content
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

cy.request with redirects is acting different on headed and headless Electron 61 #4264

Closed
DomDabrowski opened this issue May 21, 2019 · 1 comment

Comments

@DomDabrowski
Copy link

DomDabrowski commented May 21, 2019

Current behavior:

My app login system is a bit complicated (its a mix of keycloak and simplesaml). When I run my logout cy.request() through headed Electron 61 it logs me out. When I run tests on headless Electron it doesnt logs me out and says that my browser doesnt enable javascript.

Desired behavior:

I want cy.request() to act like on headed version (log me out).

Steps to reproduce: (app code and test code)

In the first spec.js I simply login and logout. In the second spec2.js I login.
With cypress open everything goes right, I arrive to spec2.js already logged out. With cypress run Im already logged in at the start of spec2.js.

This is what I get when I log all request responses with cy.task() on headless mode:

'Response Body': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n<head>\n\t<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n\t<title>POST data</title>\n</head>\n<body onload="document.getElementsByTagName(\'input\')[0].click();">\n\n\t<noscript>\n\t\t<p><strong>Note:</strong> Since your browser does not support JavaScript, you must press the button below once to proceed.</p> \n\t</noscript> \n\t\n\t<form method="post" action="${myAppUrl}">\n\t<!-- Need to add this element and call click method, because calling submit()\n\ton the form causes failed submission if the form has another element with name or id of submit.\n\tSee: https://developer.mozilla.org/en/DOM/form.submit#Specification -->\n\t<input type="submit" style="display:none;"

Versions

Cypress 3.30
Windows 10
Electron 61

@jennifer-shehane
Copy link
Member

spec files run completely isolated from one another in cypress run. State from one spec file should never be dependent on anything performed in another spec file. Running tests in parallel also does not gaurantee the specs will run in the exact same order each time.

When you do cypress open and click 'run all specs', it runs them all back to back - not really matching the same behavior as cypress run, but we intend to change this. #1586

If you want to run some shared commands across specfiles, look into using the support files. We won't be changing this behavior. https://on.cypress.io/writing-and-organizing-tests#Support-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants