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

cy.contains with selector and cy.get as a subject stopped working on v12 #25025

Closed
KrzGruszcz opened this issue Dec 7, 2022 · 4 comments · Fixed by #25035
Closed

cy.contains with selector and cy.get as a subject stopped working on v12 #25025

KrzGruszcz opened this issue Dec 7, 2022 · 4 comments · Fixed by #25035
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v12.0.0 🐛

Comments

@KrzGruszcz
Copy link

Current behavior

cy.get(<parent_locator>).contains(<child_locator>, <text>) was finding elements, but with Cypress v12.0.1 is not finding anything:

image

The changelog was not mentioning anything about cy.contains updates.

Desired behavior

should work like before changes

Test code to reproduce

describe("cy.contains bug Cypress v12.0.1", () => {
  beforeEach(() => {
    cy.visit("https://example.cypress.io");
  });

  it("passes", () => {
    cy.get(".container").eq(2).contains("p", "Commands ");
  });

  it("passes", () => {
    cy.get(".container").contains("Commands ");
  });

  it("fails", () => {
    cy.get(".container").contains("p", "Commands ");
  });
});

Cypress Version

12.0.1

Node version

v16.18.0

Operating System

macOS 13.0.1

Debug Logs

No response

Other

No response

@Develliot
Copy link

Develliot commented Dec 7, 2022

I'm also seeing issues with contains, especially inside within or when text is more than one level deep

@BlueWinds
Copy link
Contributor

Oh dear. Looking into this now; Somehow it looks like we didn't have a test case covering this case at all in our own suite.

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Dec 7, 2022
@BlueWinds
Copy link
Contributor

Linked a PR to address this. Basically, the new version of .contains() was only looking inside the first subject element - if there were multiple, everything past the first was being ignored.

Thank you for the simple repro, made this a lot easier to track down and fix quickly. Expect a patch release today or tomorrow.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 8, 2022

Released in 12.0.2.

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Dec 8, 2022
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v12.0.0 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants