A simple way to run tests
- Simple no API to learn, zero-config
- Natively supports ESM
npm install test-runner-cli
test-runner [dir|file] # default is dir `.`
Create a test file endsWith .test.js
or naming test.js
and use Node's built-in assert module, then export the test function.
import {strict as assert} from 'assert' // Node <=16
// import { equal } from 'assert/strict' // Node >=16
export function testSomeThing() {
assert.equal(1 + 2, 3)
}
Edit package.json:
{
"scripts": {
"test": "test-runner"
}
}
Run test files:
npm test // run all test files `.`
npx test-runner-cli fixtures test.js // run specify directory or file
MIT