UNPKG

@augment-vir/test

Version:

A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.

56 lines (55 loc) 1.67 kB
import { type BaseFunctionWithContext, type FunctionWithContextTestCase } from './it-cases-with-context.js'; /** * Same as `snapshotCases` but passes the test context as the first parameter to the function under * test. * * In order to generate or update the snapshot files, run tests in update mode. * * @category Test * @category Package : @augment-vir/test * @example * * ```ts * import { * snapshotCasesWithContext, * RuntimeEnv, * describe, * UniversalTestContext, * assertTestContext, * } from '@augment-vir/test'; * * function myFunctionToTest(testContext: UniversalTestContext, a: number, b: number) { * assertTestContext(testContext, RuntimeEnv.Node); * return testContext.name; * } * * describe(myFunctionToTest.name, () => { * snapshotCasesWithContext(myFunctionToTest, [ * { * it: 'handles negative numbers', * inputs: [ * -1, * -2, * ], * }, * { * it: 'handles 0', * inputs: [ * 0, * 0, * ], * }, * { * it: 'adds', * inputs: [ * 3, * 5, * ], * }, * ]); * }); * ``` * * @package [`@augment-vir/test`](https://www.npmjs.com/package/@augment-vir/test) */ export declare function snapshotCasesWithContext<const FunctionToTest extends BaseFunctionWithContext>(this: void, functionToTest: FunctionToTest, testCases: ReadonlyArray<Omit<FunctionWithContextTestCase<NoInfer<FunctionToTest>>, 'expect' | 'throws'>>): void[];