Automattic / Automattic/expect.js
[Feature] Number of expected assertions
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 207
- PR merge metrics
- No merged PRs in 30d
Description
I think it is very useful to test for a number of assertions because in asynchronous tests it's a common error that callbacks are accidentally invoked multiple times.
Maybe this way:
``` javascript
expect(someValue).to.be.ok();
expect(someOtherValue).to.be.ok();
expect.numOfTests().to.be(2);
```
An internal counter counts the number of assertions. `numOfTests()` just matches the counter with the expected number. After `numOfTests()` is called the internal counter is reset.
One problem of that approach would be if testing suites run asynchronous tests in parallel. But I'm not sure if that is usual.
What do you think?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.