11.0.0 • Published 1 year ago

test-director v11.0.0

Weekly downloads
51
License
MIT
Repository
github
Last release
1 year ago

test-director

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.

Installation

To install test-director with npm, run:

npm install test-director --save-dev

Then, import and use the class TestDirector.

Examples

A sync test:

import { equal } from "node: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 "node:assert";
import TestDirector from "test-director";

const tests = new TestDirector();

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

tests.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();

Requirements

Supported runtime environments:

  • Node.js versions ^16.9.0 || >= 18.0.0.

Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Exports

The npm package test-director features optimal JavaScript module design. These ECMAScript modules are exported via the package.json field exports:

11.0.0

1 year ago

10.0.0

2 years ago

9.0.0

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

8.0.2

2 years ago

7.0.0

3 years ago

6.0.0

3 years ago

5.0.0

3 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.0.0

5 years ago