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

Test Isolation #22230

Closed
mjhenkes opened this issue Jun 9, 2022 · 9 comments
Closed

Test Isolation #22230

mjhenkes opened this issue Jun 9, 2022 · 9 comments
Assignees
Labels
E2E Issue related to end-to-end testing Epic Requires breaking up into smaller issues topic: auth type: feature New feature that does not currently exist v12.0.0 🐛

Comments

@mjhenkes
Copy link
Member

mjhenkes commented Jun 9, 2022

Updated to reflect latest design decisions:
There will be two modes of test isolation, on and off, with on being the new default mode. When test isolation is on, before each test, Cypress will:

  • clear the page by visiting about:blank
  • clear cookies
  • clear local storage
  • clear browser storage

When test isolation is off, Cypress will not clear the browser context or the page.

@mjhenkes
Copy link
Member Author

mjhenkes commented Jun 9, 2022

We need to break this issue up into smaller issues before we assign it out.

@emilyrohrbough

This comment was marked as outdated.

@emilyrohrbough emilyrohrbough removed their assignment Jun 17, 2022
@emilyrohrbough emilyrohrbough changed the title [test-isolation] Introduce config option to disable test isolation. [epic] Test Isolation Jul 13, 2022
@nagash77 nagash77 added the Epic Requires breaking up into smaller issues label Jul 13, 2022
@emilyrohrbough

This comment was marked as outdated.

@mjhenkes mjhenkes changed the title [epic] Test Isolation Test Isolation Aug 9, 2022
@emilyrohrbough emilyrohrbough removed their assignment Sep 6, 2022
@emilyrohrbough
Copy link
Member

emilyrohrbough commented Oct 21, 2022

#24206 will close this issue with recent discussions on how test isolation is defined.

There will be two modes of test isolation, on and off, with on being the new default mode. When test isolation is on, before each test, Cypress will:

  • clear the page by visiting about:blank
  • clear cookies
  • clear local storage
  • clear browser storage

When test isolation is off, Cypress will not clear the browser context or the page.

@piotrpalek
Copy link

Are there plans to clear cy.intercept calls between tests? I'm using Cypress mostly for component testing, and it'd be desirable if I can set different interceptors per test instead of them "leaking over" to the next, and being hard to override

@emilyrohrbough
Copy link
Member

emilyrohrbough commented Dec 6, 2022

@piotrpalek EDIT: I just ran a more verbose example set per #20397, and it does not seem that Test Isolation does not completely resolves the intercept bleed-over. I ran this snippet:

for(let i = 0; i < 1000; i++) {
    it('can wait on a single request using "alias.request"', function () {
        cy.intercept('/foo*')
        .as('foo.bar')
        .then(() => {
        Cypress.$.get('/foo')
        })
        .wait('@foo.bar.request')
    })

    it('can timeout waiting on a single request using "alias.request"', function (done) {
        cy.on('fail', (err) => {
            expect(err.message).to.contain('No request ever occurred.')
            done()
        })

        cy.intercept('/foo*')
        .as('foo.bar')
        .wait('@foo.bar.request', { timeout: 100 })
    })
}

Which produced 2000 tests cases. And there were 15 failures (about 0.75% fail rate) . Leaving #20397 open as unresolved. We can have further conversations there.

@emilyrohrbough
Copy link
Member

The work related to Test Isolation has been completed. This will be released with Cypress 12.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 6, 2022

Released in 12.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E2E Issue related to end-to-end testing Epic Requires breaking up into smaller issues topic: auth type: feature New feature that does not currently exist v12.0.0 🐛
Projects
None yet
Development

No branches or pull requests

4 participants