UNPKG

3.07 kBTypeScriptView Raw
1/**
2 * @module Core
3 */
4import { Test } from '../Test';
5import { ICallback, IResolver, IGroupReport, ITestOptions, IOptions } from '../Contracts';
6/**
7 * Group holds `n` number of tests to be executed. Groups also allows
8 * defining hooks to be called before and after each test and the
9 * group itself.
10 */
11export declare class Group<T extends any[], H extends any[]> {
12 title: string;
13 private _resolveTestFn;
14 private _resolveHookFn;
15 private _options;
16 private _hooks;
17 /**
18 * Timeout defined on group will be applied to
19 * all the tests by default.
20 */
21 private _timeout;
22 /**
23 * The test error (if any)
24 */
25 private _error;
26 /**
27 * Has test been executed
28 */
29 private _completed;
30 /**
31 * An array of tests related to the group. They are mutated by the
32 * run method to filter and keep only the one's that matches
33 * the grep filter.
34 */
35 private _tests;
36 /**
37 * Storing whether the group has any failing tests or
38 * not.
39 */
40 private _hasFailingTests;
41 /**
42 * Is there a cherry picked test using the `only` property
43 * or not?
44 */
45 private _hasCherryPickedTest;
46 constructor(title: string, _resolveTestFn: IResolver<T>, _resolveHookFn: IResolver<H>, _options: IOptions);
47 /**
48 * Returns a boolean telling if group or any of the tests inside
49 * the group has errors.
50 */
51 get hasErrors(): boolean;
52 /**
53 * Filter tests if grep value is defined
54 */
55 private _filterTests;
56 /**
57 * Run a hook and if it raises error, then we will
58 * set the completed flag to true, along with the
59 * error.
60 */
61 private _runHook;
62 /**
63 * Runs a single test along side with it's hooks.
64 */
65 private _runTest;
66 /**
67 * Runs all the tests one by one and also executes
68 * the beforeEach and afterEach hooks
69 */
70 private _runTests;
71 /**
72 * Returns the JSON report for the group. The output of this
73 * method is emitted as an event.
74 */
75 toJSON(): IGroupReport;
76 /**
77 * Define timeout for all the tests inside the group. Still
78 * each test can override it's own timeout.
79 */
80 timeout(duration: number): this;
81 /**
82 * Create a new test as part of this group.
83 */
84 test(title: string, callback: ICallback<T>, testOptions?: Partial<ITestOptions>): Test<T>;
85 /**
86 * Add before hook to be executed before the group starts
87 * executing tests.
88 */
89 before(cb: ICallback<H>): this;
90 /**
91 * Add after hook to be executed after the group has executed
92 * all the tests.
93 */
94 after(cb: ICallback<H>): this;
95 /**
96 * Add before each hook to be execute before each test
97 */
98 beforeEach(cb: ICallback<H>): this;
99 /**
100 * Add after each hook to be execute before each test
101 */
102 afterEach(cb: ICallback<H>): this;
103 /**
104 * Run the group with it's hooks and all tests. Shouldn't be called
105 * by the end user and Japa itself will call this method
106 */
107 run(): Promise<void>;
108}