UNPKG

@sondr3/minitest

Version:

A low-feature, dependency-free and performant test runner inspired by Rust and Deno

102 lines 2.85 kB
export interface TestDefinition { name: string; fn: TestFn; ignore?: boolean; only?: boolean; } export type TestFn = () => void | Promise<void>; type TestNoFn = Omit<TestDefinition, "fn">; type TestOptions = Pick<TestDefinition, "ignore" | "only">; export declare class Test { private readonly name; private readonly fn; private _ignore; private _only; constructor(fnNameOrOpts: TestDefinition | TestFn | TestNoFn | string, fn?: TestFn, opts?: TestOptions); /** Mark the test as ignored */ ignore(yes?: boolean): void; /** Only run this test */ only(): void; } /** * Register a test which will be run when `mt` is used on the command line and * the containing module is a test module. `fn` can be async if required. * * ## Example: * * ```ts * import { test } from "@sondr3/minitest"; * import { strict as assert } from "node:assert"; * * test(() => { * assert(true === true, "Phew"); * }); * ``` */ export declare function test(fn: TestFn): Test; /** * Register a test which will be run when `mt` is used on the command line and * the containing module is a test module. `fn` can be async if required. * * ## Example: * * ```ts * import { test } from "@sondr3/minitest"; * import { strict as assert } from "node:assert"; * * test({ name: "example test", fn: () => { * assert(true === true, "Phew"); * }}); * ``` */ export declare function test(t: TestDefinition): Test; /** * Register a test which will be run when `mt` is used on the command line and * the containing module is a test module. `fn` can be async if required. * * ## Example: * * ```ts * import { test } from "@sondr3/minitest"; * import { strict as assert } from "node:assert"; * * test({ name: "example test" }, () => { * assert(true === true, "Phew"); * }); * ``` */ export declare function test(opts: TestNoFn, fn: TestFn): Test; /** * Register a test which will be run when `mt` is used on the command line and * the containing module is a test module. `fn` can be async if required. * * ## Example: * * ```ts * import { test } from "@sondr3/minitest"; * import { strict as assert } from "node:assert"; * * test("example test", () => { * assert(true === true, "Phew"); * }); * ``` */ export declare function test(name: string, fn: TestFn): Test; /** * Register a test which will be run when `mt` is used on the command line and * the containing module is a test module. `fn` can be async if required. * * ## Example: * * ```ts * import { test } from "@sondr3/minitest"; * import { strict as assert } from "node:assert"; * * test("example test", () => { * assert(true === true, "Phew"); * }, { ignore: true }); * ``` */ export declare function test(name: string, fn: TestFn, options?: TestOptions): Test; export {}; //# sourceMappingURL=test_fn.d.ts.map