UNPKG

5.57 kBTypeScriptView Raw
1/// <reference types="node" />
2/** Type for a callback that receives an optional error as the first argument */
3type Errback = (error?: Error) => void;
4/** Alias for setTimeout with paramaters reversed. */
5export declare function wait(delay: number, fn: (...args: any[]) => void): NodeJS.Timeout;
6/** Whether or not we are running in the node environment */
7export declare function isNode(): boolean;
8/** Whether or not stdout and stderr are interactive. */
9export declare function isTTY(): boolean;
10/** Convert a value to its boolean equivalent */
11export declare function bool(value: any): boolean | null;
12/** Whether or not colors are desired on this environment */
13export declare function useColors(): boolean;
14/** Applies the color to the value if desired */
15export declare function color(value: any, color: Function): string;
16/**
17 * Return a stringified version of the value with indentation and colors where applicable.
18 * Colors will be applied if the environment supports it (--no-colors not present and TTY).
19 * For the available options, refer to https://nodejs.org/dist/latest-v14.x/docs/api/util.html#util_util_inspect_object_options for Node.js
20 */
21export declare function inspect(value: any, opts?: any): string;
22/** Log the inspected values of each of the arguments to stdout */
23export declare function log(...args: any): void;
24/** Output a comparison of the failed result to stderr */
25export declare function logComparison(actual: any, expected: any, error: Error | string | any): void;
26/** Same as assert.strictEqual in that it performs a strict equals check, but if a failure occurs it will output detailed information */
27export declare function equal(actual: any, expected: any, testName?: string, next?: Errback): void | never;
28/** Is greater than or equal to */
29export declare function gte(actual: any, expected: any, testName?: string, next?: Errback): void | never;
30/** Is less than or equal to */
31export declare function lte(actual: any, expected: any, testName?: string, next?: Errback): void | never;
32/** Is greater than */
33export declare function gt(actual: any, expected: any, testName?: string, next?: Errback): void | never;
34/** Is less than */
35export declare function lt(actual: any, expected: any, testName?: string, next?: Errback): void | never;
36/** Ensure what is passed is undefined, otherwise fail and output what it is */
37export declare function undef(actual: any, testName?: string, next?: Errback): void;
38/** Ensure what is passed is undefined or null, otherwise fail and output what it is */
39export declare function nullish(actual: any, testName?: string, next?: Errback): void;
40/** Same as assert.deepStrictEqual in that it performs a deep strict equals check, but if a failure occurs it will output detailed information */
41export declare function deepEqual(actual: any, expected: any, testName?: string, next?: Errback): void | never;
42/** Checks to see if the actual result contains the expected result .*/
43export declare function contains(actual: any, expected: any, testName?: string, next?: Errback): void | never;
44/** Checks to see if the actual result does not contain the expected result .*/
45export declare function notContains(actual: any, expected: any, testName?: string, next?: Errback): void | never;
46/** Checks to see if an error was as expected, if a failure occurs it will output detailed information */
47export declare function errorEqual(actualError: any, expectedError: any, testName?: string, next?: Errback): void | never;
48/** Generate a callback that will return the specified value. */
49export declare function returnViaCallback(value: any): () => typeof value;
50/** Generate a callback that will receive a completion callback whcih it will call with the specified result after the specified delay. */
51export declare function completeViaCallback(value: any, delay?: number): (complete: (error: null, result: typeof value) => void) => void;
52/** Generate a callback that will receive a completion callback which it will call with the passed error after the specified delay. */
53export declare function errorViaCallback(error: Error | string, delay?: number): (complete: (error: Error | string) => void) => void;
54/** Generate a callback that return an error instance with the specified message/error. */
55export declare function returnErrorViaCallback(error?: Error | string): () => Error;
56/** Generate a callback that throw an error instance with the specified message/error. */
57export declare function throwErrorViaCallback(error?: Error | string): () => never;
58/** Generate a callback that will check the arguments it received with the arguments specified, if a failure occurs it will output detailed information. */
59export declare function expectViaCallback(...expected: any): (...actual: any) => void;
60/**
61 * Generate a callback that will check its error (the actual error) against the passed error (the expected error).
62 * If a failure occurs it will output detailed information. */
63export declare function expectErrorViaCallback(expected: Error | string, testName?: string, next?: Errback): (actual: Error | string) => void;
64/** Expect the passed function to throw an error at some point. */
65export declare function expectThrowViaFunction(expected: Error | string, fn: () => never, testName?: string, next?: Errback): void;
66/** @deprecated Use {@link expectErrorViaFunction} instead */
67export declare function expectErrorViaFunction(): never;
68/** @deprecated Use {@link expectErrorViaFunction} instead */
69export declare function expectFunctionToThrow(): never;
70export {};
71//# sourceMappingURL=index.d.ts.map
\No newline at end of file