1. @matteo.collina/tspl
Count the number of assertions for node:test
@matteo.collina/tspl
Package: @matteo.collina/tspl
Created by: mcollina
Last modified: Sun, 31 Dec 2023 21:32:43 GMT
Version: 0.1.1
License: MIT
Downloads: 8,925
Repository: https://github.com/mcollina/tspl

Install

npm install @matteo.collina/tspl
yarn add @matteo.collina/tspl

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code