Created
January 7, 2017 18:53
-
-
Save samhstn/2bc3deb53af968d0b3433720a41214db to your computer and use it in GitHub Desktop.
The uses of `t.plan`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
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