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

.each changes scope for next dual-command (like cy.contains()) #4921

Closed
dwelle opened this issue Aug 3, 2019 · 6 comments · Fixed by #8712
Closed

.each changes scope for next dual-command (like cy.contains()) #4921

dwelle opened this issue Aug 3, 2019 · 6 comments · Fixed by #8712

Comments

@dwelle
Copy link

dwelle commented Aug 3, 2019

Current behavior:

When you call .each(), e.g. on a cy.get() command, it changes the scope for next cy.contains() command.

Possibly affects other commands, and possibly calls other than .each() change the scope, too.

Originally reported here.

Steps to reproduce: (app code and test code)

describe(`test`, () => {
    it(`test`, () => {
        cy.document().then(doc => {
            doc.body.innerHTML = `
                <div class="one"></div>
                <div>Search</div>
            `;
        });
        cy.get(`.one`)
            // comment this out for the next `cy.contains` to work properly
            .each(() => {});
        cy.contains(`Search`);
    });
});

image

Versions

cypress 3.4.1

@GazEdge
Copy link

GazEdge commented Aug 3, 2019

@dwelle thanks for reporting this. I can confirm I am seeing the same issue (as per my SO post)

@jennifer-shehane
Copy link
Member

Reproducible example from #5163

it('FAILS with contains after each', () => {
  cy.visit('https://www.google.com/')
  cy.contains('About')
  cy.get('input[type="submit"]').each(() => {})
  cy.contains('About')
})

it('passes with contains after then', () => {
  cy.visit('https://www.google.com/')
  cy.contains('About')
  cy.get('input[type="submit"]').then(() => { })
  cy.contains('About')
})

it('passes with contains after should', () => {
  cy.visit('https://www.google.com/')
  cy.contains('About')
  cy.get('input[type="submit"]').should(() => { })
  cy.contains('About')
})

@jennifer-shehane
Copy link
Member

Interesting to note that this seems to happen with custom dual-commands also (aside from just cy.contains() as noted in #6550

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Mar 23, 2020

Another example from #6791

it('BUG? - breaks a following contains command', () => {
  cy.visit('https://example.cypress.io/commands/connectors')
  cy.get('.connectors-each-ul>li').each(() => {})
  cy.contains('Chai', { timeout: 10 })
})

@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress There is an open PR for this issue [WIP] labels Oct 1, 2020
@cypress-bot cypress-bot bot added the stage: pending release There is a closed PR for this issue label Oct 6, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 6, 2020

The code for this is done in cypress-io/cypress#8712, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 14, 2020

Released in 5.4.0.

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

@cypress-bot cypress-bot bot removed the stage: pending release There is a closed PR for this issue label Oct 14, 2020
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants