@litert/utils-test
v1.7.0
Published
The utility functions/classes/constants about test (using node:test) for NodeJS.
Readme
LiteRT/Utils - Test
The utility functions/classes/constants about test (using node:test) for NodeJS.
Requirement
- TypeScript v5.0.0 (or newer)
- Node.js v18.0.0 (or newer)
Installation
npm i @litert/utils-test --saveAPIs
Function autoTick
The autoTick function is a utility for testing asynchronous code that relies on mocked timers.
It automatically advances the timer and executes any pending asynchronous operations,
making it easier to write tests for code that uses setTimeout, setInterval, or
other timer-based functions.
import { autoTick } from '@litert/utils-test';
await autoTick(async () => {
// Some asynchronous operation that uses timers
await new Promise((resolve) => setTimeout(resolve, 1000));
console.log('This will be logged after the timer is advanced');
});Documentation
License
This library is published under Apache-2.0 license.
