donc
v1.4.0
Published
Minimalistic test runner that does NOT dynamically require test files. And so `donc --inspect-brk` will have all project files loaded.
Downloads
10
Readme
Donc
Minimalistic, debugger friendly test runner for Node.
Features
- fast
- runs test for a line number (failing tests can be rerun by copying a line from a stacktrace)
- inspector friendly (copies debug url to clipboard; loads test files before initial
--inspect-brk
breakpoint) - no nesting (nested
describe
/context
s spread test setup all over the test file, making it difficult to follow) - no separate
after*
callbacks (instead eachbefore*
can register cleanup) - includes typescript type declarations
Usage
Install:
npm i --save-dev donc
Write a test test/firstTest.js
:
const {test} = require('donc')
const assert = require('assert')
test('first passing test', () => {
assert.ok(true)
})
test('first failing test', async () => {
assert.equal(1, 2)
})
Run all tests:
./node_modules/.bin/donc test/**/*Test.js
Run individual test:
# by line number
./node_modules/.bin/donc test/someTest.js:123
# or using --only option
./node_modules/.bin/donc --only='when bananas' test/someTest.js
Other things available:
it
which is an alias fortest
test.only()
to run single test (also available as a command line argument:--only='some test'
)beforeEach()
to run some code before each test in a filebeforeFile()
to run some code before all tests in a filebeforeSuite()
to run some code before all tests
Each hook callback is passed a cleanup function:
beforeEach(async (cleanup) => {
const server = new Server()
await server.start()
// can be invoked multiple times
cleanup(async () => await server.stop())
})