cy.visit('about:blank') navigates to http://url/base/about:blank
cy.visit('about:blank') navigates to about:blank
3.4.1
In our application we register some listener on storage events. During before each cypress cleans the storage. This results into failing in our application, because our application is still running from the previous test case.
It should be possible to leave our application for example in after each by visiting about:blank.
I think the easiest way would be adding another option parameter to the visit command to skip adding base url to the target url:
https://github.com/cypress-io/cypress/blob/49f5b3e80c56e382b3cbd37c6deedda7389c32b7/packages/driver/src/cy/commands/navigation.coffee#L555-L563
Our current workaround is patching the register event listener method on window:load.
@CSchulz This is currently not possible. The only way to do this would be to have your webserver would need to serve an empty page that you could then visit.
But we've discussed having Cypress serve a blank page so that you can reset things like this, something like cy.reset()
You can try using the test code below, but this may not perform the way you think it should exactly since there is still some persistence of state when visiting about:blank manually in this way.
cy.window().then((win) => {
win.location.href = 'about:blank'
})
I just spent quite a while debugging a similar issue. It's very unexpected that the page from a previous test is still open causing things to happen and can fail the current test. Hugely in favor of a cy.reset().
Most helpful comment
@CSchulz This is currently not possible. The only way to do this would be to have your webserver would need to serve an empty page that you could then visit.
But we've discussed having Cypress serve a blank page so that you can reset things like this, something like
cy.reset()You can try using the test code below, but this may not perform the way you think it should exactly since there is still some persistence of state when visiting
about:blankmanually in this way.