donc
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

Donc Codeship Status for artemave/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/contexts spread test setup all over the test file, making it difficult to follow)
  • no separate after* callbacks (instead each before* 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 for test
  • 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 file
  • beforeFile() to run some code before all tests in a file
  • beforeSuite() 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())
})

Readme

Keywords

none

Package Sidebar

Install

npm i donc

Weekly Downloads

4

Version

1.4.0

License

MIT

Unpacked Size

25.9 kB

Total Files

37

Last publish

Collaborators

  • artemavetisyan