Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
jennifer-shehane opened this issue Feb 10, 2020 · 8 comments · Fixed by #6434
Closed

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

jennifer-shehane opened this issue Feb 10, 2020 · 8 comments · Fixed by #6434
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: regression A bug that didn't appear until a specific Cy version release v4.0.0 🐛 Issue present since 4.0.0

Comments

@jennifer-shehane
Copy link
Member

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

@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory type: regression A bug that didn't appear until a specific Cy version release v4.0.0 🐛 Issue present since 4.0.0 labels Feb 10, 2020
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Feb 10, 2020
@sainthkh sainthkh self-assigned this Feb 10, 2020
@sainthkh
Copy link
Contributor

sainthkh commented Feb 10, 2020

It has nothing to do with #5653. (No, #5653 caused it. I checked it.)

For some reason, obj.is(selector) || !!obj.find(selector).length is false false in 3.8.3, but true false in 4.0.1.

Needs investigating.

@brian-mann
Copy link
Member

Did we update a dependency in 4.0.0 that introduced this? Did we keep jquery versions the same? We've seen that be the root cause before.

@brian-mann
Copy link
Member

Actually this might have to do with chai maybe?

@brian-mann
Copy link
Member

/cc @chrisbreiding and @bkucera

@sainthkh
Copy link
Contributor

Sorry, I was wrong. #5653 introduced this regression.

@kuceb
Copy link
Contributor

kuceb commented Feb 11, 2020

@sainthkh no worries, it was broken before that if you used a regex, but no one noticed. I'm working on the fix, which should clean up some logic.

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs investigating Someone from Cypress needs to look at this stage: work in progress stage: needs review The PR code is done & tested, needs review labels Feb 12, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 14, 2020

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

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Feb 14, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 14, 2020

Released in 4.0.2.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Feb 14, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: regression A bug that didn't appear until a specific Cy version release v4.0.0 🐛 Issue present since 4.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants