test-runner
Minimal, extensible test runner.
Last updated 9 years ago by 75lb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install test-runner 
SYNC missed versions from official npm registry.

view on npm npm module downloads Build Status Dependency Status js-standard-style

test-runner

A minimal test runner built around a single, core principle: if a test function completes successfully (or fulfils), it passes. If it throws (or rejects) it fails. It has no opinion how you write tests, or which (if any) assertion library you use.

const TestRunner = require('test-runner')
const runner = new TestRunner()

Synopsis

Passing test, sync.

runner.test('this will pass', function () {
  const thought = 'Nothing failing here.'
})

Passing test, async.

runner.test('this will also pass', function () {
  return Promise.resolve('Nothing failing here.')
})

Failing test, sync.

runner.test('this will fail', function () {
  throw new Error('Definitely something wrong here.')
})

Failing test, async.

runner.test('this will also fail', function () {
  return Promise.reject('Definitely something wrong here.')
})

To run the tests, execute the script:

$ node test.js

... or use the command-line tool to test multiple files:

$ test-runner test/*.js

test-runner

TestRunner ⇐ EventEmitter ⏏

Register tests and run them sequentially or in parallel. By default, testing begins automatically but can be set to start manually.

Kind: Exported class
Extends: EventEmitter

new TestRunner([options])

Param Type Description
[options] object
[options.log] function Specify a custom log function. Defaults to console.log.
[options.manualStart] boolean If true, you must call runner.start() manually.
[options.sequential] boolean Run async tests sequentially.

testRunner.start() ⇒ Promise

Begin testing. You'll only need to use this method when manualStart is true.

Kind: instance method of TestRunner
Fulfil: Array - Resolves with an array containing the return value of each test.

testRunner.test(name, testFunction) ↩︎

Register a test.

Kind: instance method of TestRunner
Chainable

Param Type Description
name string Each name supplied must be unique to the runner instance.
testFunction function The test function. If it throws or rejects, the test will fail.

testRunner.skip() ↩︎

No-op. Use this method when you want a test to be skipped.

Kind: instance method of TestRunner
Chainable

testRunner.only(name, testFunction) ↩︎

Only run this and other tests registered with only.

Kind: instance method of TestRunner
Chainable

Param Type
name string
testFunction function

TestRunner.run(globs) ⇒ Array

Run one or more test files. The output will be an array containing the export value from each module.

Kind: static method of TestRunner

Param Type Description
globs Array.<string> One or more file paths or glob expressions.

© 2016-18 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Current Tags

  • 0.11.1                                ...           latest (2 years ago)
  • 0.12.0-10                                ...           next (a month ago)

95 Versions

  • 0.12.0-10                                ...           a month ago
  • 0.12.0-9                                ...           4 months ago
  • 0.11.1                                ...           2 years ago
  • 0.12.0-8                                ...           2 years ago
  • 0.12.0-7                                ...           2 years ago
  • 0.12.0-6                                ...           2 years ago
  • 0.12.0-5                                ...           2 years ago
  • 0.12.0-4                                ...           2 years ago
  • 0.12.0-3                                ...           2 years ago
  • 0.12.0-2                                ...           2 years ago
  • 0.12.0-1                                ...           2 years ago
  • 0.12.0-0                                ...           2 years ago
  • 0.11.0                                ...           2 years ago
  • 0.10.1                                ...           5 years ago
  • 0.10.0                                ...           5 years ago
  • 0.9.8                                ...           5 years ago
  • 0.9.7                                ...           5 years ago
  • 0.9.6                                ...           5 years ago
  • 0.9.5                                ...           5 years ago
  • 0.9.4                                ...           5 years ago
  • 0.9.3                                ...           5 years ago
  • 0.9.2                                ...           6 years ago
  • 0.9.1                                ...           6 years ago
  • 0.9.0                                ...           6 years ago
  • 0.8.14                                ...           6 years ago
  • 0.8.13                                ...           7 years ago
  • 0.8.12                                ...           7 years ago
  • 0.8.11                                ...           7 years ago
  • 0.8.10                                ...           7 years ago
  • 0.8.9                                ...           7 years ago
  • 0.8.8                                ...           7 years ago
  • 0.8.7                                ...           7 years ago
  • 0.8.6                                ...           7 years ago
  • 0.8.5                                ...           7 years ago
  • 0.8.4                                ...           7 years ago
  • 0.8.3                                ...           7 years ago
  • 0.8.2                                ...           7 years ago
  • 0.8.1                                ...           7 years ago
  • 0.8.0                                ...           7 years ago
  • 0.7.7                                ...           7 years ago
  • 0.7.6                                ...           7 years ago
  • 0.7.5                                ...           7 years ago
  • 0.7.4                                ...           7 years ago
  • 0.7.3                                ...           7 years ago
  • 0.7.2                                ...           7 years ago
  • 0.7.1                                ...           7 years ago
  • 0.7.0                                ...           7 years ago
  • 0.6.3                                ...           7 years ago
  • 0.6.2                                ...           7 years ago
  • 0.6.1                                ...           7 years ago
  • 0.6.0                                ...           8 years ago
  • 0.6.0-15                                ...           8 years ago
  • 0.6.0-14                                ...           8 years ago
  • 0.6.0-13                                ...           8 years ago
  • 0.6.0-12                                ...           8 years ago
  • 0.6.0-11                                ...           8 years ago
  • 0.6.0-10                                ...           8 years ago
  • 0.6.0-9                                ...           8 years ago
  • 0.6.0-8                                ...           8 years ago
  • 0.6.0-7                                ...           8 years ago
  • 0.6.0-6                                ...           8 years ago
  • 0.6.0-5                                ...           8 years ago
  • 0.6.0-4                                ...           8 years ago
  • 0.6.0-3                                ...           8 years ago
  • 0.6.0-2                                ...           8 years ago
  • 0.5.1                                ...           8 years ago
  • 0.6.0-1                                ...           9 years ago
  • 0.6.0-0                                ...           9 years ago
  • 0.5.0                                ...           9 years ago
  • 0.5.0-1                                ...           9 years ago
  • 0.5.0-0                                ...           9 years ago
  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.0                                ...           10 years ago
  • 0.2.5                                ...           10 years ago
  • 0.2.4                                ...           10 years ago
  • 0.2.3                                ...           10 years ago
  • 0.2.2                                ...           10 years ago
  • 0.2.1                                ...           10 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.13                                ...           10 years ago
  • 0.1.12                                ...           10 years ago
  • 0.1.11                                ...           10 years ago
  • 0.1.10                                ...           10 years ago
  • 0.1.9                                ...           10 years ago
  • 0.1.8                                ...           10 years ago
  • 0.1.7                                ...           10 years ago
  • 0.1.6                                ...           10 years ago
  • 0.1.5                                ...           10 years ago
  • 0.1.4                                ...           10 years ago
  • 0.1.3                                ...           10 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
  • 0.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 485
Today 0
This Week 23
This Month 199
Last Day 4
Last Week 22
Last Month 143
Dependencies (7)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE