Namespace Test
Package: @litert/utils-test
Test helper utilities for the Node.js built-in test runner (node:test). Provides functions that automatically advance mocked timers so that timer-dependent async tests complete instantly without real delays, and a helper to temporarily override environment variables.
Install
Use this namespace only:
bash
npm i @litert/utils-testOr install the full bundle:
bash
npm i @litert/utilsAnd then import from it.
ts
import * as LibUtils from '@litert/utils';
await LibUtils.Test.autoTick(myTimerTask);
// or
import { Test as LibTest } from '@litert/utils';
await LibTest.autoTick(myTimerTask);Functions
| Function | Description |
|---|---|
autoTick | Advances mocked timers via runAll() on every event loop tick until the task settles. |
autoTickMs | Advances the mocked clock by a fixed interval (tickMs) per event loop tick until the task settles. |
withEnv | Temporarily sets environment variables for the duration of a callback and restores them afterward. |