Skip to content

cy.contains('xxx').should('not.exist') try to expect <body> not to exist in the DOM #14861

@aNyMoRe0505

Description

@aNyMoRe0505

Current behavior

I try to test input validation by cypress
When user enter page first time, user should not see the error message
So I write test like this
cy.contains('forgot_password_error_email_empty').should('not.exist');
but it seems that command try to expect body not to exist in the DOM so it fails in the end

2

When I reproduced my problem, I found this bug is related to next-i18n and only occur in next production build
If I have translation key test (public/static/locales/en) cy.contains('test').should('not.exist') will check body exist or not

If I write cy.contains with selector cy.contains('span', 'test').should('not.exist'), the test will pass.
But I think this is not the good solution.

Desired behavior

cy.contains should not check the body

Test code to reproduce

clone this project (https://github.com/aNyMoRe0505/next-cypress)
npm install => npm run build => npm run start
then npm run cypress:open to execute test

if you run in dev mode (npm run dev) everything works fine.

Versions

"cypress": "^6.3.0"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions