# test-director

> An ultra lightweight unit test director for Node.js.

Latest version **11.0.0** (published 2023-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install test-director
pnpm add test-director
yarn add test-director
bun add test-director
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 11.0.0 |
| Published | 2023-02-27 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | ^16.9.0 \|\| >= 18.0.0 |
| Dependencies | 2 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Jayden Seric |
| Maintainers | jaydenseric |
| Keywords | test, director, esm, mjs |

## Links

- npm: https://www.npmjs.com/package/test-director
- Repository: https://github.com/jaydenseric/test-director
- Homepage: https://github.com/jaydenseric/test-director#readme
- Issues: https://github.com/jaydenseric/test-director/issues
- Funding: https://github.com/sponsors/jaydenseric
- npm.io page: https://npm.io/package/test-director

## Dependencies (2)

- [kleur](https://npm.io/package/kleur.md) ^4.1.5
- [@types/node](https://npm.io/package/@types/node.md) *

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 11.0.0 (latest) — 2023-02-27
- 10.0.0 — 2022-08-18
- 9.0.0 — 2022-08-17
- 8.0.2 — 2022-02-09
- 8.0.1 — 2021-12-26
- 8.0.0 — 2021-12-26
- 7.0.0 — 2021-11-02
- 6.0.0 — 2021-04-26
- 5.0.0 — 2020-12-07
- 4.0.1 — 2020-05-04
- 4.0.0 — 2020-03-24
- 3.0.1 — 2020-01-26
- 3.0.0 — 2019-12-23
- 2.0.0 — 2019-12-10
- 1.0.0 — 2019-10-17

## README

# 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](https://nodejs.org/api/assert.html) and [`snapshot-assertion`](https://npm.im/snapshot-assertion).

Use [`coverage-node`](https://npm.im/coverage-node) to run your test script and report code coverage.

## Installation

To install [`test-director`](https://npm.im/test-director) with [npm](https://npmjs.com/get-npm), run:

```sh
npm install test-director --save-dev
```

Then, import and use the class [`TestDirector`](./TestDirector.mjs).

## Examples

A sync test:

```js
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:

```js
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:

```js
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](https://nodejs.org) versions `^16.9.0 || >= 18.0.0`.

Projects must configure [TypeScript](https://typescriptlang.org) to use types from the ECMAScript modules that have a `// @ts-check` comment:

- [`compilerOptions.allowJs`](https://typescriptlang.org/tsconfig#allowJs) should be `true`.
- [`compilerOptions.maxNodeModuleJsDepth`](https://typescriptlang.org/tsconfig#maxNodeModuleJsDepth) should be reasonably large, e.g. `10`.
- [`compilerOptions.module`](https://typescriptlang.org/tsconfig#module) should be `"node16"` or `"nodenext"`.

## Exports

The [npm](https://npmjs.com) package [`test-director`](https://npm.im/test-director) features [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design). These ECMAScript modules are exported via the [`package.json`](./package.json) field [`exports`](https://nodejs.org/api/packages.html#exports):

- [`TestDirector.mjs`](./TestDirector.mjs)

---
_Source: https://npm.io/package/test-director · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
