Reputation: 6449
I'm writing Cypress tests and running them headless in terminal. The tests are passing even when they should fail.
For example writing this code:
describe('Website Landing', () => {
it.only('Should load', async () => {
cy.visit('http://www.mywebsite.com/');
cy.get('[data-testid="sign-inx"]');
})
})
And running this on terminal will end on success:
cypress run
But there is no element with such attribute and value. And if I add other assertions at the end, the test keeps passing
cy.get('[data-testid="sign-inx"]').should('have.length', 1);
I don't understand how Cypress manages to allow tests to pass and to fail. Could someone help?
Cypress version is 13.15.1
Upvotes: 1
Views: 69
Reputation: 3210
Get rid of the async
keyword.
Here is the same run with and without it. Note the difference in timing, the test runner seems to be expecting something that does not occur.
Upvotes: 5