@systemix/runner
Minimal test runner for Systemix packages. Zero dependencies. Part of the Systemix toolkit.
Installation
pnpm add -D @systemix/runner
Usage
createRunner + runSuites (multi-suite)
import { createRunner, runSuites } from '@systemix/runner';
const loadSuite = createRunner(({ assert, assertThrows }) => {
assert(1 + 1 === 2, 'math works');
assertThrows(() => {
throw new Error('expected');
}, 'throws');
});
const parseSuite = createRunner(({ assert }) => {
assert(true, 'parse ok');
});
runSuites(
[
{ name: 'load', ...loadSuite },
{ name: 'parse', ...parseSuite },
],
{ packageName: '@systemix/env' },
);
Single suite (run)
import { createRunner, run } from '@systemix/runner';
const suite = createRunner(({ assert, assertThrows }) => {
assert(foo() === 'bar', 'foo returns bar');
assertThrows(() => bad(), 'bad throws');
});
await run(suite, { packageName: '@systemix/password' });
Or with runSuites:
import { createRunner, runSuites } from '@systemix/runner';
const suite = createRunner(({ assert, assertThrows }) => {
assert(foo() === 'bar', 'foo returns bar');
assertThrows(() => bad(), 'bad throws');
});
await runSuites([suite], { packageName: '@systemix/password' });
Async tests
const { run, getCounts } = createRunner(
({ assert, assertThrows, assertThrowsAsync }) => {
assert(sync(), 'sync works');
await assertThrowsAsync(async () => await badAsync(), 'async throws');
}
);
API
| Export | Description |
|---|---|
createRunner | Returns { run, getCounts }. Suite receives { assert, assertThrows, assertThrowsAsync }. |
runSuites | Runs suites, prints summary, exits with 0 or 1. options.packageName for header. |
run | Run a single suite and exit. Convenience for one-suite packages. |