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.
npm i @matteo.collina/tspl --save-dev
(You'll also need @types/node
)
import test from 'node:test';
import { tspl } from '@matteo.collina/tspl';
test('tspl', (t) => {
const { strictEqual } = tspl(t, { plan: 1 });
strictEqual(1, 1);
});
import test from 'node:test';
import { tspl, type Plan } from '@matteo.collina/tspl';
test('tspl', (t) => {
const p: Plan = tspl(t, { plan: 1 });
p.strictEqual(1, 1);
});
Create a plan for the current test.
Here are the options:
plan
: how many assertions are planned
The plan includes all exports from node:assert
,
as well as:
end()
: a function to complete the plancompleted
: a promise that will resolve when the plan is completed.
MIT