function Test.the
the<
T extends Testing,
U,
>
(
name: string | null,
step0?: Fn<unknown[], U>,
step1?: Fn<[U, T], unknown>,
...steps: unknown[],
): Step<T, void>

Test case. Consists of name and zero or more test steps.

  1. Steps run in sequence. If no step throws, the case passes.
  2. Empty case like the('empty') amounts to the('empty', todo()).
  3. Stringy step like the('empty', 'string') amounts to the('empty', the('string'))
  4. Falsy step like the('something', null) is only counted.

Example:

import { suite, the, ok, equal } from '@hackbg/fadroma';

export const test1 = the('Thing',
  _ => ok(1 == 1)                       // unnamed step (sync)
  async _ => ok(await something() != 5) // unnamed step (async)
);

export const test2 = the('Other',
  test1,                                // include defined substep
  the('named step', _ => equal(1, 1)),  // define named substep in place
  the('renamed step', test1)            // rename defined substep
);

export default suite(import.meta, 'Test suite', test2);

Type Parameters

T extends Testing

Parameters

name: string | null
optional
step0: Fn<unknown[], U>
optional
step1: Fn<[U, T], unknown>
...steps: unknown[]

Return Type

Step<T, void>

Usage

import { Test } from ".";