Debian Codegraph @

debian/tests/test_modules/@matteo.collina/tspl/README.md

raw symbols SCIP
1 # tspl
2
3 Test Planner for [`node:test`](https://nodejs.org/api/test.html)
4 and [`node:assert`](https://nodejs.org/api/assert.html).
5 It fails your tests if the number of assertions is not met,
6 or the test plan was not completed.
7
8 ## Install
9
10 ```bash
11 npm i @matteo.collina/tspl
12 ```
13
14 (You'll also need `@types/node`)
15
16 ## Example
17
18 ```js
19 import test from 'node:test'
20 import { tspl } from '@matteo.collina/tspl'
21
22 test('tspl', (t) => {
23 const { strictEqual } = tspl(t, { plan: 1 })
24 strictEqual(1, 1)
25 })
26 ```
27
28 ### Typescript
29
30 ```typescript
31 import test from 'node:test';
32 import { tspl, Plan } from '@matteo.collina/tspl';
33
34 test('tspl', (t) => {
35 const p: Plan = tspl(t, { plan: 1 });
36 strictEqual(1, 1);
37 });
38 ```
39
40 ## API
41
42 ### __`tspl(t: TestContext, options): Plan`__
43
44 Create a plan for the current test.
45
46 Here are the options:
47
48 * `plan`: how many assertions are planned
49
50 ### `Plan`
51
52 The plan includes all exports from [`node:assert`](https://nodejs.org/api/assert.html),
53 as well as:
54
55 * `end()`: a function to complete the plan
56 * `completed`: a promise that will resolve when the plan is completed.
57
58 ## License
59
60 MIT