Console test runner - writes to stdin, reads stdout
npm install tests
|20||downloads in the last month|
|Version||0.4.2 last updated a year ago|
|Keywords||test, console, stdin, stdout|
|Dependencies||mocha, chai, walkdir|
Console Test Runner: writes to stdin, reads stdout.
tests.js is useful for test-driven development of command-line utilities. Works on Mac OS X, Windows and Linux so you can write cross-platform tests. Tests do not depend on the implementation language of the program.
You will need Node.js and NPM. Install using the following command.
$ npm install -g tests
Then create some
.test files and execute the following command in the folder
Test files should have the following structure.
first line—command to execute (can be relative path, can contain pipeline of several commands),
<<<and input to send to the program (can be multiple lines),
>>>and expected output.
wc <<< one two three >>> 1 3 14
This test executes
wc command, sends string
one two three to its stdin and
checks the output of the program.
When the test is run you should see something like
✓ /path/to/tests/wc.test: 9ms ✔ 1 test complete (9ms)
To compare program’s output with expected output not as literal strings but as
JSON objects write
>>>JSON in the test file instead of
For more examples see https://github.com/sheremetyev/texts.js/tree/master/test.
The idea was borrowed from John MacFarlane’s tests format in Pandoc2.