-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Assertion on getCookie() is called twice in the Cypress runner #6672
Comments
Yeah...not sure why it's doing that. This began happening in Cypress 4.0.0. There's a lot of changes in 4.0.0, but my complete guess is maybe it involves the Chai upgrade #2862.
it('cookie verification', () => {
cy.visit('https://example.cypress.io/commands/cookies')
cy.get('#getCookie .set-a-cookie').click()
cy.getCookie('token').should('exist')
}); 3.8.14.0.0+The below code does not log the assertion twice. it('cookie verification', () => {
cy.visit('https://example.cypress.io/commands/cookies')
cy.get('#getCookie .set-a-cookie').click()
cy.getCookie('token').then((cookie) => {
expect(cookie).to.exist
})
}); |
I had a look at this and it looks like the change in #2862 that is causing the assertion to run twice is: https://github.com/cypress-io/cypress/pull/2862/files#diff-462c090a4a1cf87c581bae15f3af0d6aR111 It looks the same behaviour has been ported from the Coffescript to the Javascript version of Example spec it('cookie verification', () => {
cy.visit('https://example.cypress.io/commands/cookies')
cy.get('#getCookie .set-a-cookie').click()
cy.getCookie('token').should('exist')
}); Running the spec against latest developRunning the spec against #8246I don't really understand why the code was introduced in the first place but it looks like most checks pass against the draft pull request I opened. Is there anything else you would like me to do or look at before requesting a review for the pull request? |
@Tomastomaslol The PR will require tests to ensure that this is no longer logging twice in the UI. There's some idea of what these tests look like around command logs here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/cypress/integration/commands/cookies_spec.js#L174:L174 |
@jennifer-shehane Thanks for your pointer. I opened a pull request that should fix the described issue. If you have a spare minute please let me know what you think of my proposed solution. I really enjoyed working with the codebase and hopefully there will be other opportunities for me to contribute in the future! Have a good Friday! 🙂 |
The code for this is done in cypress-io/cypress#8276, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
I am asserting
cy.getCookie()
only once in my code, but the Cypress runner shows the assertion happened twice. Though it is a very minor and low priority issue, it is not the most optimum as the logic for validating the cookie fromcypress-runner.js
is being called twice and adds to the execution time.Desired behavior:
Cypress runner should show the
ASSERT
log only once forcy.getCookie('auth').should('exist')
Test code to reproduce
Both the
ASSERT
s print exactly the same message from the same line number of the Cypress runner source codecypress-runner.js:168422
to the DevTools consoleVersions
Cypress:
OS:
Browser:
The text was updated successfully, but these errors were encountered: