Allow multiple expect() calls within one test
See original GitHub issueHi there,
are there any plans to support multiple expects in one test (similar to what jasmine offers)?
When:
it('foo', function () {
expect(3==2).to.be.true;
expect(4==3).to.be.true;
expect(4==2).to.be.true;
});
Then: The test run should results in s.th. like:
AssertionError: expected false to be true
...
AssertionError: expected false to be true
...
AssertionError: expected false to be true
...
instead of just one AssertionError.
Regards, Leif
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
chai-as-promised: multiple expect statements in a single test
This allows multiple Chai assertions (and perhaps some other assertion libraries) in the same test and will report on all of the failures....
Read more >Is it OK to have multiple asserts in a single unit test?
If you need to test multiple fields of a result or multiple results of a single operation, you absolutely should assert all of...
Read more >Stop requiring only one assertion per unit test
One way to handle this is to refactor the test code into a method that can then be shared between two separate tests....
Read more >Expect - Jest
The expect function is used every time you want to test a value. You will rarely call expect by itself. Instead, you will...
Read more >Mocking a JavaScript Class with Jest, two ways to make it easier
For instance, if a test is doing an HTTP call to another server and that server is down for 1 hour, your unit...
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
Usually I use the & (and) to concatenate the expects that is only one.
expect(3==2).to.be.true && expect(4==3).to.be.true && expect(4==2).to.be.true;
Also you can use the || (or) too. I hope this help you.
This was very helpful! I can’t believe I didn’t think of something so simple. Thank you so much!