Assertion failure in async test case does not fail test overall
See original GitHub issueRelated issues
- https://brucelefebvre.com/blog/2019/08/26/cypress-gotchas-with-promises/
- https://github.com/cypress-io/cypress/issues/1417 (this is more about using
async
/await
with the Cypress API,cy.xxx
) - https://github.com/cypress-io/cypress/issues/3724
- https://github.com/cypress-io/cypress/issues/3883
- https://github.com/cypress-io/cypress/issues/3497
Current behavior:
The assertion fails(in red) but the overall test still passes,
Desired behavior:
Asserts with cy
work in async
test case
Steps to reproduce: (app code and test code)
Use the following testing code with async
and notice the test succeeds.
https://github.com/MadLittleMods/cypress-test-tiny/pull/1/files
const generateFixtures = function() {
return new Promise(resolve => {
setTimeout(() => {
resolve("bar");
}, 1000);
});
};
describe("Some page", function() {
it("shows something", async function() {
const fixtures = await generateFixtures();
cy.visit(`http://google.com/?foo=${fixtures}`);
cy.contains("somethingthatodoesNOTexist");
});
});
Versions
- Cypress 3.4.0
- Node v10.15.1
- Windows 10
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:53 (22 by maintainers)
Top Results From Across the Web
mocha test passes even when assertion fail if async function ...
If an exception is thrown by the test case (i.e., by the assertion library), the test is deemed to have failed.
Read more >Assert | Node.js v19.3.0 Documentation
If asyncFn is a function and it throws an error synchronously, assert.doesNotReject() will return a rejected Promise with that error. If the function...
Read more >Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run ......
Read more >unittest — Unit testing framework — Python 3.11.1 ...
test fixture. A test fixture represents the preparation needed to perform one or more tests, and any associated cleanup actions. This may involve,...
Read more >Assert | Basic Guides | Guides | Docs - TestCafe
test ('Button click', async t => { const btn = Selector('#btn'); await t .click(btn) // A regular assertion fails immediately, but TestCafe retries...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What is the point of having testing tool that doesn’t even assert properly? This should have P1
Can someone guide me to related code?
Very helpful blog post @bahmutov! This approach solved my issue: