Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/tspl
Test Planner for node:test
https://github.com/mcollina/tspl
Last synced: 6 days ago
JSON representation
Test Planner for node:test
- Host: GitHub
- URL: https://github.com/mcollina/tspl
- Owner: mcollina
- License: mit
- Created: 2023-07-20T16:53:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-17T13:31:18.000Z (6 months ago)
- Last Synced: 2024-12-08T14:35:36.842Z (14 days ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 27
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tspl
Test Planner for [`node:test`](https://nodejs.org/api/test.html)
and [`node:assert`](https://nodejs.org/api/assert.html).
It fails your tests if the number of assertions is not met,
or the test plan was not completed.## Installation
```bash
npm i @matteo.collina/tspl --save-dev
```(You'll also need `@types/node`)
## Example
```js
import test from 'node:test';
import { tspl } from '@matteo.collina/tspl';test('tspl', (t) => {
const { strictEqual } = tspl(t, { plan: 1 });
strictEqual(1, 1);
});
```### Typescript
```typescript
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);
});
```## 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`](https://nodejs.org/api/assert.html),
as well as:* `end()`: a function to complete the plan
* `completed`: a promise that will resolve when the plan is completed.## License
MIT