td

test-director

An ultra lightweight unit test director for Node.js.

Showing:

Popularity

Downloads/wk

14

GitHub Stars

11

Maintenance

Last Commit

5mos ago

Contributors

0

Package

Dependencies

2

Size (min+gzip)

2.9KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

test-director

npm version CI status

An ultra lightweight unit test director for Node.js.

Works well with any assertion library that throws errors, such as the Node.js assert API and snapshot-assertion.

Use coverage-node to run your test script and report code coverage.

Setup

To install from npm run:

npm install test-director --save-dev

Support

API

Table of contents

class TestDirector

An ultra lightweight unit test director for Node.js.

Examples

How to import.

import TestDirector from 'test-director';

How to construct a new instance.

const tests = new TestDirector();

TestDirector instance method add

Adds a test.

ParameterTypeDescription
namestringUnique test name.
testFunctionTest to run; may return a Promise.
Examples

A sync test.

import { equal } from 'assert';
import TestDirector from 'test-director';

const tests = new TestDirector();

tests.add('JavaScript addition.', () => {
  equal(1 + 1, 2);
});

tests.run();

An async test.

import { ok } from 'assert';
import fetch from 'node-fetch';
import TestDirector from 'test-director';

const tests = new TestDirector();

tests.add('GitHub is up.', async () => {
  const { ok } = await fetch('https://github.com');
  ok(ok);
});

tests.run();

TestDirector instance method run

Runs the tests one after another, in the order they were added.

ParameterTypeDescription
throwOnFailureboolean? = falseAfter tests run, throw an error if some failed.

Returns: Promise\ — Resolves once tests have run.

Examples

Run nested tests.

import TestDirector from 'test-director';

const tests = new TestDirector();

tests.add('Test A.', async () => {
  const tests = new TestDirector();

  tests.add('Test B.', () => {
    // …
  });

  tests.add('Test C.', () => {
    // …
  });

  await tests.run(true);
});

tests.add('Test D.', () => {
  // …
});

tests.run();

TestDirector instance property tests

A map of test functions that have been added, keyed by their test names.

Type: Map\<string, Function>

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100