Skip to content

cy.contains() falsely failing when using negative assertion 'not.contain' #6384

Description

@jennifer-shehane

Current behavior:

When I use the not.contain assertion chained off of .contains(), it falsely fails. I suspect this is some regression introduced in #5653 cc @sainthkh

3.8.3

Screen Shot 2020-02-10 at 1 28 51 PM

4.0.0

Screen Shot 2020-02-10 at 1 25 10 PM

Desired behavior:

The div does not contain the text new and should pass.

Test code to reproduce

index.html

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
  <div>actions.spec.js</div>
</body>
</html>

This test falsely fails ❌

it('repro', () => {
  cy.visit('index.html')
  cy.contains('actions.spec.js')
    .should('not.contain', 'new')
})

This test passes though ✅

This makes me believe it has to do with the return value of cy.contains()

it('repro', () => {
  cy.visit('index.html')
  cy.get('div')
    .should('not.contain', 'new') // passes
})

And this passes though ✅

it('repro', () => {
  cy.visit('index.html')
  cy.contains('actions.spec.js').then((el) => {
    
  }).should('not.contain', 'new') // passes
})

Versions

Cypress 4.0.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

pkg/driverThis is due to an issue in the packages/driver directorytype: regressionA bug that didn't appear until a specific Cy version releasev4.0.0 🐛Issue present since 4.0.0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions