shy

0.3.3 • Public • Published

shy

shy is a simple mocha extension that enables to write functional tests for your node based command line application.

Let's create the simplest cli app possible: echojs

First install the required dependencies

npm install mocha shy --save-dev

Create the executable js file (./bin/echojs.js)

#!/usr/bin/env node
process.stdout.write(process.argv.slice(2).join(' ') + '\n');

Configure package.json properly

...
"bin": {
	"echojs": "./bin/echojs.js"
},
"scripts": {
    "test": "./node_modules/.bin/_mocha --compilers shy:shy 
}
...

Write a simple functional test (./test/multi_input.shy)

shy track 'echojs hello world'

shy assert {stdout} = "hello world\n"

Run the tests

npm test

Readme

Keywords

Package Sidebar

Install

npm i shy

Weekly Downloads

4

Version

0.3.3

License

MIT

Last publish

Collaborators

  • tamasflamich