@matteo.collina/tspl
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

tspl

Test Planner for node:test and node:assert. It fails your tests if the number of assertions is not met, or the test plan was not completed.

Install

npm i @matteo.collina/tspl

(You'll also need @types/node)

Example

import test from 'node:test'
import { tspl } from '@matteo.collina/tspl'

test('tspl', (t) => {
  const { strictEqual } = tspl(t, { plan: 1 })
  strictEqual(1, 1)
})

Typescript

import test from 'node:test';
import { tspl, Plan } from '@matteo.collina/tspl';

test('tspl', (t) => {
  const p: Plan = tspl(t, { plan: 1 });
  strictEqual(1, 1);
});

API

tspl(t: TestContext, options): Plan

Create a plan for the current test.

Here are the options:

  • plan: how many assertions are planned

Plan

The plan includes all exports from node:assert, as well as:

  • end(): a function to complete the plan
  • completed: a promise that will resolve when the plan is completed.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @matteo.collina/tspl

Weekly Downloads

2,195

Version

0.1.1

License

MIT

Unpacked Size

7.29 kB

Total Files

10

Last publish

Collaborators

  • matteo.collina