UNPKG

2.44 kBTypeScriptView Raw
1/**
2 * A function defining a new test case or a test suite, e.g. `it` or `describe`.
3 */
4export declare type TestDefinition<ARGS extends unknown[], RETVAL> = (name: string, ...args: ARGS) => RETVAL;
5/**
6 * Helper function for skipping tests when a certain condition is met.
7 *
8 * @example
9 * ```ts
10 * skipIf(
11 * !features.freeFormProperties,
12 * describe,
13 * 'free-form properties (strict: false)',
14 * () => {
15 * // the tests
16 * }
17 * );
18 * ```
19 *
20 * @param skip - Should the test case/suite be skipped?
21 * @param verb - The function to invoke to define the test case or the test
22 * suite, e.g. `it` or `describe`.
23 * @param name - The test name (the first argument of `verb` function).
24 * @param args - Additional arguments (framework specific), typically a function
25 * implementing the test.
26 */
27export declare function skipIf<ARGS extends unknown[], RETVAL>(skip: boolean, verb: TestDefinition<ARGS, RETVAL> & {
28 skip: TestDefinition<ARGS, RETVAL>;
29}, name: string, ...args: ARGS): RETVAL;
30/**
31 * Helper function for skipping tests on Travis CI.
32 *
33 * @example
34 *
35 * ```ts
36 * skipOnTravis(it, 'does something when some condition', async () => {
37 * // the test
38 * });
39 * ```
40 *
41 * @param verb - The function to invoke to define the test case or the test
42 * suite, e.g. `it` or `describe`.
43 * @param name - The test name (the first argument of `verb` function).
44 * @param args - Additional arguments (framework specific), typically a function
45 * implementing the test.
46 */
47export declare function skipOnTravis<ARGS extends unknown[], RETVAL>(verb: TestDefinition<ARGS, RETVAL> & {
48 skip: TestDefinition<ARGS, RETVAL>;
49}, name: string, ...args: ARGS): RETVAL;
50/*** LEGACY API FOR BACKWARDS COMPATIBILITY ***/
51export interface TestFn {
52 (this: TestContext): PromiseLike<unknown>;
53 (this: TestContext, done: Function): void;
54}
55export interface TestContext {
56 skip(): this;
57 timeout(ms: number | string): this;
58 retries(n: number): this;
59 slow(ms: number): this;
60 [index: string]: any;
61}
62/**
63 * Helper function for skipping tests on Travis env - legacy variant
64 * supporting `it` only.
65 *
66 * @param expectation - The test name (the first argument of `it` function).
67 * @param callback - The test function (the second argument of `it` function).
68 *
69 * @deprecated Use `skipOnTravis(it, name, fn)` instead.
70 */
71export declare function itSkippedOnTravis(expectation: string, callback?: TestFn): void;