UNPKG

2.58 kBTypeScriptView Raw
1/**
2 * @module Core
3 */
4import { ITestOptions, ITestReport, ICallback, IResolver } from '../Contracts';
5/**
6 * Test class is used for running and defining a test. It supports following
7 * top level config properties.
8 *
9 * - skip : Skip the test
10 * - skipInCI : Skip the test on CI
11 * - runInCI : Run only in CI
12 */
13export declare class Test<T extends any[]> {
14 title: string;
15 private _resolveFn;
16 private _callback;
17 /**
18 * When the callback for the function is not defined, then we mark
19 * the test as todo
20 */
21 private _todo;
22 /**
23 * Mark failed tests as passed
24 */
25 private _regression;
26 /**
27 * Regression message is set when the passes, but it was meant
28 * to fail
29 */
30 private _regressionMessage;
31 /**
32 * The test timeout. It can be overridden at multiple levels
33 */
34 private _timeout;
35 /**
36 * How many times, we should retry the function before marking
37 * it as failed
38 */
39 private _retries;
40 /**
41 * The time spent to run the test. This includes the hooks
42 * time.
43 */
44 private _duration;
45 /**
46 * The test error (if any)
47 */
48 private _error;
49 /**
50 * Whether or not to skip the test
51 */
52 private _skip;
53 /**
54 * Has test been executed
55 */
56 private _completed;
57 constructor(title: string, _resolveFn: IResolver<T>, _callback: ICallback<T> | undefined, options: ITestOptions);
58 /**
59 * Returns a boolean, telling if exception is hard. Hard exceptions
60 * fails the regression tests too
61 */
62 private get _isHardException();
63 /**
64 * Runs test for given number retries
65 */
66 private _runTest;
67 /**
68 * The JSON representation of the test. This is emitted
69 * as an event to show test state.
70 */
71 toJSON(): ITestReport;
72 /**
73 * Retry a test for the given number of counts, before marking
74 * it as failed.
75 */
76 retry(counts: number): this;
77 /**
78 * Set explicit timeout for the given test.
79 */
80 timeout(duration: number): this;
81 /**
82 * Runs the test. If retries are defined, then the test will be retried for the
83 * given number of times before marked as failed. When retrying hooks are not
84 * executed again.
85 *
86 * ```js
87 * // stack
88 * [before hook 1, before hook 2]
89 * [test] (2 retries)
90 * [after hook 1]
91 *
92 * + before hook 1
93 * + before hook 2
94 * test (original attempt = failed)
95 * test (1st attempt = passed)
96 * + after hook 1
97 * ```
98 */
99 run(): Promise<void>;
100}