Automattic / Automattic/expect.js

[Feature] Number of expected assertions

Open
#27 2 comments 1 reaction 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.