Skip to content

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

Closed
@KrzGruszcz

Description

@KrzGruszcz

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

Metadata

Metadata

Assignees

Labels

type: regressionA bug that didn't appear until a specific Cy version releasev12.0.0 🐛

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions