Testing CLI tool to test javascript apps
To install testme
, type
$ git clone https://github.com/DevTMK/testme.git
$ cd testme
$ npm install
$ npm link
Then run this command inside a project folder
$ testme
Let's get started by writing a test for a function that adds two numbers. First, create a add.js file:
function add(a, b) {
return a + b
}
module.exports = add
Then, create a file named add.test.js. This will contain our actual test:
const add = require('./add')
test('adds 1 + 2 to equal 3', () => {
expect(add(1, 2)).toBe(3)
})
Add the following section to your package.json:
Finally, run npm run test
or yarn test
and it will print this message:
RUNS add.test.js
✔ adds 1 + 2 to equal 3