My JavaScript testing stack
After releasing a dozen or so npm modules I’ve settled on a testing stack that I enjoy using.
For writing tests I use tape. I’ve used it ever since I started leaning towards test-driven development (except for a brief stint with Mocha). I’ve written two formatters for consuming its TAP output, but these days I tend to stick with the default output since I only want to know if my tests pass or not.
I also use smokestack for running my tests in the browser in conjunction with browserify and tap-closer. It’s not a foolproof system since it’ll only run the tests in the browser that I’m currently using (the latest stable version of Chrome), but it gives me a general idea if the module works or not.
For code coverage I use covert. I agree with substack that “most code coverage libraries do weird things […], such as writing all their junk to directories and files in a completely out-of-band way”. covert only ever writes the results directly to stdout or stderr.
My testing related npm scripts looks like this:
The above setup makes it easy to switch between them by typing npm run
test[:<type>]
1.
-
On a semi-related note I’ve also switched to the same namespacing technique for build scripts too. ↩