A zero configuration, zero dependency test runner for ECMAScript Modules—made specifically for getting started quick. Painless migration to the bigger guns if you end up needing them.
import test from 'oletus'
// this should look pretty familiar
test('arrays are equal', t => {
t.deepEqual([1, 2], [1, 2])
})
Install it with npm:
npm install --save-dev oletus
Add the test script to your package.json
, using the native --experimental-modules:
"scripts": {
"test": "npx -n='--experimental-modules --no-warnings' oletus"
},
Alternatively, you can use the esm package for wider support:
"scripts": {
"test": "npx -n='-r esm' oletus"
},
Write your test modules in a /test/
directory:
import test from 'oletus'
test('foo', t => {
t.ok(true)
})
test('bar', async t => {
const bar = Promise.resolve('bar')
t.equal(await bar, 'bar')
})
It's also possible to run tests that match a pattern passed in as a command-line argument.
oletus src/**/*.test.mjs
Oletus has a concise reporter on local runs and a verbose reporter on CI environments.
The imported test
is an async function that expects the title
and implementation
of the test to be passed in as arguments. The implementation has a single parameter (t
, for example) that gets passed the strict node assertion module.
Joonatan Vuorinen (@bearror)