Skip to content

Instantly share code, notes, and snippets.

@samhstn
Created January 7, 2017 18:53
Show Gist options
  • Save samhstn/2bc3deb53af968d0b3433720a41214db to your computer and use it in GitHub Desktop.
Save samhstn/2bc3deb53af968d0b3433720a41214db to your computer and use it in GitHub Desktop.
The uses of `t.plan`
```
test(‘test it errors at some point’, (t) => {
asyncEvent(‘data that will error’, (err, cb) => {
if (err) {
t.ok(err);
t.end();
}
anotherAsyncEvent((err, cb) => {
if (err) {
t.ok(err);
t.end();
}
});
});
});
```
You can use `t.plan(1)` at the top. Or if you want to ensure a particular test runs as mentioned [here](https://ponyfoo.com/articles/testing-javascript-modules-with-tape).
As also mentioned in the article, “going for simply t.end will save you the hassle of updating t.plan statements with the correct assertion count” which is my main issue with the syntax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment