1.4.0 • Published 5 years ago
donc v1.4.0
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-brkbreakpoint) - no nesting (nested
describe/contexts 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 doncWrite 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.jsRun 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.jsOther things available:
itwhich is an alias fortesttest.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())
})