When writing my node modules, I’ve come to really quite enjoy using Jest for testing (I’ve written about how I used tap and it’s quite similar).
Sometimes however, being able to execute the module on the command line and passing some arbitrary data can be pretty handy, and I’ve used the following technique on a growing handful of modules I’ve written.
Exporting to the CLII’ve written a module called bin-to-file. It’s an old JS Bin module that takes a bin structure and returns a single HTML string with everything smooshed together.
The module has tests, but I want to be able to quickly test the output using the command line like this:
$ cat __test__/foo.json | node lib/index.js