I'm using Cypress for e2e tests in an angular web app. When cypress first opens it goes to http://localhost:54401/__/#tests/integration/login.spec.ts
This shows the cypress test dock on the left side of the screen and the web output to the right. As soon as my beforeEach
function calls cy.visit()
, instead of changing the output, the main url at the top of the screen changes to:
http://localhost:4200/__/#tests/integration/login.spec.ts
Angular then takes over, it can't find the __
route, so instead the page is redirected to my default page, and I lose the Cypress dock/test runner.
Cypress should just be changing the frame where my application is loaded, not the page url. Something is happening that is causing Cypress to manipulate the main browser url instead of the frame url.
How can this be fixed so that cypress targets the frame and not the main browser window? This has worked in the past and just recently started not working. I'm not sure if it's a cypress or chrome issue. I thought this may be an issue with cypress web security so I did try setting chromeWebSecurity: false
in cypress.json
to no avail.
https://docs.cypress.io/guides/guides/web-security.html#Disabling-Web-Security
I'm using cypress 3.1.5.
Filed a bug with the Cypress github project and was informed this usually occurs when an application has framebusting code. Turns out we were importing hammerjs
. When I removed that import (in polyfills.js), it works fine.
import 'hammerjs';
For reference, the issue link is Entire test runner redirects to app's login page #3517
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With