cy.contains('xxx').should('not.exist') try to expect <body> not to exist in the DOM #14879
Unanswered
aNyMoRe0505
asked this question in
Questions and Help
Replies: 1 comment
-
Hey @aNyMoRe0505 You could rather do this : |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I don't know If I can repost here, I have already posted an issue
Please let me know if I need to delete this discussion or not.
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
When I reproduced my problem, I found this bug is related to
next-i18n
and only occur innext production build
If I have translation key
test
(public/static/locales/en)cy.contains('test').should('not.exist')
will check body exist or notIf 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.
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"
Beta Was this translation helpful? Give feedback.
All reactions