@japa/runner 3.0.0-6 → 3.0.0-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/chunk-7THDHQFT.js +283 -0
- package/build/chunk-HN4AVHWN.js +17 -0
- package/build/chunk-MCOW34SG.js +269 -0
- package/build/chunk-W5IABAQU.js +502 -0
- package/build/factories/main.d.ts +42 -2
- package/build/factories/main.js +209 -13
- package/build/index.d.ts +14 -9
- package/build/index.js +237 -202
- package/build/main-63126780.d.ts +109 -0
- package/build/modules/core/main.d.ts +3 -62
- package/build/modules/core/main.js +21 -121
- package/build/src/reporters/main.d.ts +9 -4
- package/build/src/reporters/main.js +11 -37
- package/build/src/types.d.ts +23 -19
- package/build/src/types.js +14 -9
- package/package.json +41 -32
- package/build/factories/runner.d.ts +0 -27
- package/build/factories/runner.js +0 -206
- package/build/modules/core/reporters/base.d.ts +0 -41
- package/build/modules/core/reporters/base.js +0 -183
- package/build/modules/core/types.d.ts +0 -5
- package/build/modules/core/types.js +0 -9
- package/build/src/cli_parser.d.ts +0 -14
- package/build/src/cli_parser.js +0 -75
- package/build/src/config_manager.d.ts +0 -18
- package/build/src/config_manager.js +0 -168
- package/build/src/create_test.d.ts +0 -21
- package/build/src/create_test.js +0 -53
- package/build/src/debug.d.ts +0 -3
- package/build/src/debug.js +0 -10
- package/build/src/exceptions_manager.d.ts +0 -19
- package/build/src/exceptions_manager.js +0 -85
- package/build/src/files_manager.d.ts +0 -18
- package/build/src/files_manager.js +0 -57
- package/build/src/helpers.d.ts +0 -22
- package/build/src/helpers.js +0 -10
- package/build/src/hooks.d.ts +0 -20
- package/build/src/hooks.js +0 -46
- package/build/src/planner.d.ts +0 -25
- package/build/src/planner.js +0 -98
- package/build/src/plugins/retry.d.ts +0 -20
- package/build/src/plugins/retry.js +0 -66
- package/build/src/reporters/dot.d.ts +0 -15
- package/build/src/reporters/dot.js +0 -41
- package/build/src/reporters/ndjson.d.ts +0 -15
- package/build/src/reporters/ndjson.js +0 -86
- package/build/src/reporters/spec.d.ts +0 -13
- package/build/src/reporters/spec.js +0 -154
- package/build/src/validator.d.ts +0 -30
- package/build/src/validator.js +0 -85
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @japa/runner
|
|
3
|
-
*
|
|
4
|
-
* (c) Japa
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import assert from 'node:assert';
|
|
10
|
-
import { fileURLToPath } from 'node:url';
|
|
11
|
-
import { Planner } from '../src/planner.js';
|
|
12
|
-
import { GlobalHooks } from '../src/hooks.js';
|
|
13
|
-
import { CliParser } from '../src/cli_parser.js';
|
|
14
|
-
import { ConfigManager } from '../src/config_manager.js';
|
|
15
|
-
import { createTest, createTestGroup } from '../src/create_test.js';
|
|
16
|
-
import { Suite, Runner, Emitter } from '../modules/core/main.js';
|
|
17
|
-
/**
|
|
18
|
-
* Runner factory exposes the API to run dummy suites, groups and tests.
|
|
19
|
-
* You might want to use the factory for testing reporters and
|
|
20
|
-
* plugins usage
|
|
21
|
-
*/
|
|
22
|
-
export class RunnerFactory {
|
|
23
|
-
#emitter = new Emitter();
|
|
24
|
-
#config;
|
|
25
|
-
#cliArgs;
|
|
26
|
-
#suites;
|
|
27
|
-
#file = fileURLToPath(import.meta.url);
|
|
28
|
-
get #refiner() {
|
|
29
|
-
return this.#config.refiner;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creating unit and functional suites
|
|
33
|
-
*/
|
|
34
|
-
#createSuites() {
|
|
35
|
-
return [
|
|
36
|
-
new Suite('unit', this.#emitter, this.#refiner),
|
|
37
|
-
new Suite('functional', this.#emitter, this.#refiner),
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates a variety of tests for Maths.add method
|
|
42
|
-
*/
|
|
43
|
-
#createAdditionTests(group) {
|
|
44
|
-
createTest('add two numbers', this.#emitter, this.#refiner, { group, file: this.#file }).run(() => {
|
|
45
|
-
assert.equal(2 + 2, 4);
|
|
46
|
-
});
|
|
47
|
-
createTest('add three numbers', this.#emitter, this.#refiner, {
|
|
48
|
-
group,
|
|
49
|
-
file: this.#file,
|
|
50
|
-
}).run(() => {
|
|
51
|
-
assert.equal(2 + 2 + 2, 6);
|
|
52
|
-
});
|
|
53
|
-
createTest('add group of numbers', this.#emitter, this.#refiner, { group, file: this.#file });
|
|
54
|
-
createTest('use math.js lib', this.#emitter, this.#refiner, { group, file: this.#file }).skip(true, 'Library work pending');
|
|
55
|
-
createTest('add multiple numbers', this.#emitter, this.#refiner, {
|
|
56
|
-
file: this.#file,
|
|
57
|
-
group,
|
|
58
|
-
}).run(() => {
|
|
59
|
-
assert.equal(2 + 2 + 2 + 2, 6);
|
|
60
|
-
});
|
|
61
|
-
createTest('add floating numbers', this.#emitter, this.#refiner, { group, file: this.#file })
|
|
62
|
-
.run(() => {
|
|
63
|
-
assert.equal(2 + 2.2 + 2.1, 6);
|
|
64
|
-
})
|
|
65
|
-
.fails('Have to add support for floating numbers');
|
|
66
|
-
createTest('A test with an error that is not an AssertionError', this.#emitter, this.#refiner, {
|
|
67
|
-
group,
|
|
68
|
-
file: this.#file,
|
|
69
|
-
}).run(() => {
|
|
70
|
-
throw new Error('This is an error');
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Creates a variety of dummy tests for creating
|
|
75
|
-
* a new user
|
|
76
|
-
*/
|
|
77
|
-
#createUserStoreTests(group) {
|
|
78
|
-
createTest('Validate user data', this.#emitter, this.#refiner, {
|
|
79
|
-
group,
|
|
80
|
-
file: this.#file,
|
|
81
|
-
}).run(() => { });
|
|
82
|
-
createTest('Disallow duplicate emails', this.#emitter, this.#refiner, {
|
|
83
|
-
group,
|
|
84
|
-
file: this.#file,
|
|
85
|
-
}).run(() => { });
|
|
86
|
-
createTest('Disallow duplicate emails across tenants', this.#emitter, this.#refiner, {
|
|
87
|
-
group,
|
|
88
|
-
file: this.#file,
|
|
89
|
-
}).run(() => {
|
|
90
|
-
const users = ['', ''];
|
|
91
|
-
assert.equal(users.length, 1);
|
|
92
|
-
});
|
|
93
|
-
createTest('Normalize email before persisting it', this.#emitter, this.#refiner, {
|
|
94
|
-
group,
|
|
95
|
-
file: this.#file,
|
|
96
|
-
}).skip(true, 'Have to build a normalizer');
|
|
97
|
-
createTest('Send email verification mail', this.#emitter, this.#refiner, {
|
|
98
|
-
group,
|
|
99
|
-
file: this.#file,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates tests for the unit tests suite
|
|
104
|
-
*/
|
|
105
|
-
#createUnitTests(suite) {
|
|
106
|
-
const additionGroup = createTestGroup('Maths#add', this.#emitter, this.#refiner, {
|
|
107
|
-
suite,
|
|
108
|
-
file: this.#file,
|
|
109
|
-
});
|
|
110
|
-
this.#createAdditionTests(additionGroup);
|
|
111
|
-
createTest('A top level test inside a suite', this.#emitter, this.#refiner, {
|
|
112
|
-
suite,
|
|
113
|
-
file: this.#file,
|
|
114
|
-
}).run(() => { });
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Creates tests for the functional tests suite
|
|
118
|
-
*/
|
|
119
|
-
#createFunctionalTests(suite) {
|
|
120
|
-
const usersStoreGroup = createTestGroup('Users/store', this.#emitter, this.#refiner, {
|
|
121
|
-
suite,
|
|
122
|
-
file: this.#file,
|
|
123
|
-
});
|
|
124
|
-
this.#createUserStoreTests(usersStoreGroup);
|
|
125
|
-
const usersListGroup = createTestGroup('Users/list', this.#emitter, this.#refiner, {
|
|
126
|
-
suite,
|
|
127
|
-
file: this.#file,
|
|
128
|
-
});
|
|
129
|
-
usersListGroup.setup(() => {
|
|
130
|
-
throw new Error('Unable to cleanup database');
|
|
131
|
-
});
|
|
132
|
-
createTest('A test that will never because the group hooks fails', this.#emitter, this.#refiner, { group: usersListGroup });
|
|
133
|
-
createTest('A top level test inside functional suite', this.#emitter, this.#refiner, {
|
|
134
|
-
suite,
|
|
135
|
-
file: this.#file,
|
|
136
|
-
}).run(() => { });
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Registers plugins
|
|
140
|
-
*/
|
|
141
|
-
async #registerPlugins(runner) {
|
|
142
|
-
for (let plugin of this.#config.plugins) {
|
|
143
|
-
await plugin({
|
|
144
|
-
config: this.#config,
|
|
145
|
-
runner,
|
|
146
|
-
emitter: this.#emitter,
|
|
147
|
-
cliArgs: this.#cliArgs,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Configure runner
|
|
153
|
-
*/
|
|
154
|
-
configure(config, argv) {
|
|
155
|
-
this.#cliArgs = new CliParser().parse(argv || []);
|
|
156
|
-
this.#config = new ConfigManager(config, this.#cliArgs).hydrate();
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Register custom suites to execute instead
|
|
161
|
-
* of the dummy one's
|
|
162
|
-
*/
|
|
163
|
-
withSuites(suites) {
|
|
164
|
-
this.#suites = suites;
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Define a custom emitter instance to use
|
|
169
|
-
*/
|
|
170
|
-
useEmitter(emitter) {
|
|
171
|
-
this.#emitter = emitter;
|
|
172
|
-
return this;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Run dummy tests. You might use
|
|
176
|
-
*/
|
|
177
|
-
async run() {
|
|
178
|
-
const runner = new Runner(this.#emitter);
|
|
179
|
-
await this.#registerPlugins(runner);
|
|
180
|
-
const { config, reporters, refinerFilters } = await new Planner(this.#config).plan();
|
|
181
|
-
const globalHooks = new GlobalHooks();
|
|
182
|
-
globalHooks.apply(config);
|
|
183
|
-
reporters.forEach((reporter) => {
|
|
184
|
-
runner.registerReporter(reporter);
|
|
185
|
-
});
|
|
186
|
-
refinerFilters.forEach((filter) => {
|
|
187
|
-
config.refiner.add(filter.layer, filter.filters);
|
|
188
|
-
});
|
|
189
|
-
if (this.#suites) {
|
|
190
|
-
this.#suites.forEach((suite) => runner.add(suite));
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
const [unit, functional] = this.#createSuites();
|
|
194
|
-
this.#createUnitTests(unit);
|
|
195
|
-
runner.add(unit);
|
|
196
|
-
this.#createFunctionalTests(functional);
|
|
197
|
-
runner.add(functional);
|
|
198
|
-
}
|
|
199
|
-
await globalHooks.setup(runner);
|
|
200
|
-
await runner.start();
|
|
201
|
-
await runner.exec();
|
|
202
|
-
await runner.end();
|
|
203
|
-
await globalHooks.teardown(null, runner);
|
|
204
|
-
return runner.getSummary();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { TestEndNode, SuiteEndNode, GroupEndNode, TestStartNode, RunnerSummary, RunnerEndNode, GroupStartNode, SuiteStartNode, RunnerStartNode, BaseReporterOptions } from '../types.js';
|
|
2
|
-
import { Emitter, Runner } from '../main.js';
|
|
3
|
-
/**
|
|
4
|
-
* Base reporter to build custom reporters on top of
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class BaseReporter {
|
|
7
|
-
#private;
|
|
8
|
-
runner?: Runner;
|
|
9
|
-
/**
|
|
10
|
-
* Path to the file for which the tests are getting executed
|
|
11
|
-
*/
|
|
12
|
-
currentFileName?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Suite for which the tests are getting executed
|
|
15
|
-
*/
|
|
16
|
-
currentSuiteName?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Group for which the tests are getting executed
|
|
19
|
-
*/
|
|
20
|
-
currentGroupName?: string;
|
|
21
|
-
constructor(options?: BaseReporterOptions);
|
|
22
|
-
/**
|
|
23
|
-
* Handlers to capture events
|
|
24
|
-
*/
|
|
25
|
-
protected onTestStart(_: TestStartNode): void;
|
|
26
|
-
protected onTestEnd(_: TestEndNode): void;
|
|
27
|
-
protected onGroupStart(_: GroupStartNode): void;
|
|
28
|
-
protected onGroupEnd(_: GroupEndNode): void;
|
|
29
|
-
protected onSuiteStart(_: SuiteStartNode): void;
|
|
30
|
-
protected onSuiteEnd(_: SuiteEndNode): void;
|
|
31
|
-
protected start(_: RunnerStartNode): Promise<void>;
|
|
32
|
-
protected end(_: RunnerEndNode): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Print tests summary
|
|
35
|
-
*/
|
|
36
|
-
protected printSummary(summary: RunnerSummary): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Invoked by the tests runner when tests are about to start
|
|
39
|
-
*/
|
|
40
|
-
boot(runner: Runner, emitter: Emitter): void;
|
|
41
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @japa/runner
|
|
3
|
-
*
|
|
4
|
-
* (c) Japa
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import ms from 'ms';
|
|
10
|
-
import colors from '@poppinss/colors';
|
|
11
|
-
import { ErrorsPrinter } from '@japa/errors-printer';
|
|
12
|
-
const ansi = colors.ansi();
|
|
13
|
-
/**
|
|
14
|
-
* Base reporter to build custom reporters on top of
|
|
15
|
-
*/
|
|
16
|
-
export class BaseReporter {
|
|
17
|
-
#options;
|
|
18
|
-
runner;
|
|
19
|
-
/**
|
|
20
|
-
* Path to the file for which the tests are getting executed
|
|
21
|
-
*/
|
|
22
|
-
currentFileName;
|
|
23
|
-
/**
|
|
24
|
-
* Suite for which the tests are getting executed
|
|
25
|
-
*/
|
|
26
|
-
currentSuiteName;
|
|
27
|
-
/**
|
|
28
|
-
* Group for which the tests are getting executed
|
|
29
|
-
*/
|
|
30
|
-
currentGroupName;
|
|
31
|
-
constructor(options = {}) {
|
|
32
|
-
this.#options = Object.assign({ stackLinesCount: 2 }, options);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Pretty prints the aggregates
|
|
36
|
-
*/
|
|
37
|
-
#printAggregates(summary) {
|
|
38
|
-
const tests = [];
|
|
39
|
-
/**
|
|
40
|
-
* Set value for tests row
|
|
41
|
-
*/
|
|
42
|
-
if (summary.aggregates.passed) {
|
|
43
|
-
tests.push(ansi.green(`${summary.aggregates.passed} passed`));
|
|
44
|
-
}
|
|
45
|
-
if (summary.aggregates.failed) {
|
|
46
|
-
tests.push(ansi.red(`${summary.aggregates.failed} failed`));
|
|
47
|
-
}
|
|
48
|
-
if (summary.aggregates.todo) {
|
|
49
|
-
tests.push(ansi.cyan(`${summary.aggregates.todo} todo`));
|
|
50
|
-
}
|
|
51
|
-
if (summary.aggregates.skipped) {
|
|
52
|
-
tests.push(ansi.yellow(`${summary.aggregates.skipped} skipped`));
|
|
53
|
-
}
|
|
54
|
-
if (summary.aggregates.regression) {
|
|
55
|
-
tests.push(ansi.magenta(`${summary.aggregates.regression} regression`));
|
|
56
|
-
}
|
|
57
|
-
this.runner.summaryBuilder.use(() => {
|
|
58
|
-
return [
|
|
59
|
-
{
|
|
60
|
-
key: ansi.dim('Tests'),
|
|
61
|
-
value: `${tests.join(', ')} ${ansi.dim(`(${summary.aggregates.total})`)}`,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
key: ansi.dim('Time'),
|
|
65
|
-
value: ansi.dim(ms(summary.duration)),
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
|
-
});
|
|
69
|
-
console.log(this.runner.summaryBuilder.build().join('\n'));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Aggregates errors tree to a flat array
|
|
73
|
-
*/
|
|
74
|
-
#aggregateErrors(summary) {
|
|
75
|
-
const errorsList = [];
|
|
76
|
-
summary.failureTree.forEach((suite) => {
|
|
77
|
-
suite.errors.forEach((error) => errorsList.push({ title: suite.name, ...error }));
|
|
78
|
-
suite.children.forEach((testOrGroup) => {
|
|
79
|
-
/**
|
|
80
|
-
* Suite child is a test
|
|
81
|
-
*/
|
|
82
|
-
if (testOrGroup.type === 'test') {
|
|
83
|
-
testOrGroup.errors.forEach((error) => {
|
|
84
|
-
errorsList.push({ title: `${suite.name} / ${testOrGroup.title}`, ...error });
|
|
85
|
-
});
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Suite child is a group
|
|
90
|
-
*/
|
|
91
|
-
testOrGroup.errors.forEach((error) => {
|
|
92
|
-
errorsList.push({ title: testOrGroup.name, ...error });
|
|
93
|
-
});
|
|
94
|
-
testOrGroup.children.forEach((test) => {
|
|
95
|
-
test.errors.forEach((error) => {
|
|
96
|
-
errorsList.push({ title: `${testOrGroup.name} / ${test.title}`, ...error });
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
return errorsList;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Pretty print errors
|
|
105
|
-
*/
|
|
106
|
-
async #printErrors(summary) {
|
|
107
|
-
if (!summary.failureTree.length) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const errorPrinter = new ErrorsPrinter({
|
|
111
|
-
stackLinesCount: this.#options.stackLinesCount,
|
|
112
|
-
framesMaxLimit: this.#options.framesMaxLimit,
|
|
113
|
-
});
|
|
114
|
-
errorPrinter.printSectionHeader('ERRORS');
|
|
115
|
-
await errorPrinter.printErrors(this.#aggregateErrors(summary));
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Handlers to capture events
|
|
119
|
-
*/
|
|
120
|
-
onTestStart(_) { }
|
|
121
|
-
onTestEnd(_) { }
|
|
122
|
-
onGroupStart(_) { }
|
|
123
|
-
onGroupEnd(_) { }
|
|
124
|
-
onSuiteStart(_) { }
|
|
125
|
-
onSuiteEnd(_) { }
|
|
126
|
-
async start(_) { }
|
|
127
|
-
async end(_) { }
|
|
128
|
-
/**
|
|
129
|
-
* Print tests summary
|
|
130
|
-
*/
|
|
131
|
-
async printSummary(summary) {
|
|
132
|
-
await this.#printErrors(summary);
|
|
133
|
-
console.log('');
|
|
134
|
-
if (summary.aggregates.total === 0 && !summary.hasError) {
|
|
135
|
-
console.log(ansi.bgYellow().black(' NO TESTS EXECUTED '));
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (summary.hasError) {
|
|
139
|
-
console.log(ansi.bgRed().black(' FAILED '));
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
console.log(ansi.bgGreen().black(' PASSED '));
|
|
143
|
-
}
|
|
144
|
-
console.log('');
|
|
145
|
-
this.#printAggregates(summary);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Invoked by the tests runner when tests are about to start
|
|
149
|
-
*/
|
|
150
|
-
boot(runner, emitter) {
|
|
151
|
-
this.runner = runner;
|
|
152
|
-
emitter.on('test:start', (payload) => {
|
|
153
|
-
this.currentFileName = payload.meta.fileName;
|
|
154
|
-
this.onTestStart(payload);
|
|
155
|
-
});
|
|
156
|
-
emitter.on('test:end', (payload) => {
|
|
157
|
-
this.onTestEnd(payload);
|
|
158
|
-
});
|
|
159
|
-
emitter.on('group:start', (payload) => {
|
|
160
|
-
this.currentGroupName = payload.title;
|
|
161
|
-
this.currentFileName = payload.meta.fileName;
|
|
162
|
-
this.onGroupStart(payload);
|
|
163
|
-
});
|
|
164
|
-
emitter.on('group:end', (payload) => {
|
|
165
|
-
this.currentGroupName = undefined;
|
|
166
|
-
this.onGroupEnd(payload);
|
|
167
|
-
});
|
|
168
|
-
emitter.on('suite:start', (payload) => {
|
|
169
|
-
this.currentSuiteName = payload.name;
|
|
170
|
-
this.onSuiteStart(payload);
|
|
171
|
-
});
|
|
172
|
-
emitter.on('suite:end', (payload) => {
|
|
173
|
-
this.currentSuiteName = undefined;
|
|
174
|
-
this.onSuiteEnd(payload);
|
|
175
|
-
});
|
|
176
|
-
emitter.on('runner:start', async (payload) => {
|
|
177
|
-
await this.start(payload);
|
|
178
|
-
});
|
|
179
|
-
emitter.on('runner:end', async (payload) => {
|
|
180
|
-
await this.end(payload);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CLIArgs } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* CLI Parser is used to parse the commandline argument
|
|
4
|
-
*/
|
|
5
|
-
export declare class CliParser {
|
|
6
|
-
/**
|
|
7
|
-
* Parses command-line arguments
|
|
8
|
-
*/
|
|
9
|
-
parse(argv: string[]): CLIArgs;
|
|
10
|
-
/**
|
|
11
|
-
* Returns the help string
|
|
12
|
-
*/
|
|
13
|
-
getHelp(): string;
|
|
14
|
-
}
|
package/build/src/cli_parser.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @japa/runner
|
|
3
|
-
*
|
|
4
|
-
* (c) Japa
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
// @ts-ignore-error
|
|
10
|
-
import getopts from 'getopts';
|
|
11
|
-
import colors from '@poppinss/colors';
|
|
12
|
-
const ansi = colors.ansi();
|
|
13
|
-
/**
|
|
14
|
-
* Known commandline options. The user can still define additional flags and they
|
|
15
|
-
* will be parsed aswell, but without any normalization
|
|
16
|
-
*/
|
|
17
|
-
const OPTIONS = {
|
|
18
|
-
string: ['tests', 'groups', 'tags', 'files', 'timeout', 'retries', 'reporter', 'failed'],
|
|
19
|
-
boolean: ['help', 'matchAll', 'failed'],
|
|
20
|
-
alias: {
|
|
21
|
-
forceExit: 'force-exit',
|
|
22
|
-
matchAll: 'match-all',
|
|
23
|
-
help: 'h',
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Help string to display when the `--help flag is used`
|
|
28
|
-
*/
|
|
29
|
-
const GET_HELP = () => `
|
|
30
|
-
${ansi.yellow('@japa/runner v2.3.0')}
|
|
31
|
-
|
|
32
|
-
${ansi.green('--tests')} ${ansi.dim('Filter tests by the test title')}
|
|
33
|
-
${ansi.green('--groups')} ${ansi.dim('Filter tests by the group title')}
|
|
34
|
-
${ansi.green('--tags')} ${ansi.dim('Filter tests by tags')}
|
|
35
|
-
${ansi.green('--files')} ${ansi.dim('Filter tests by the file name')}
|
|
36
|
-
${ansi.green('--force-exit')} ${ansi.dim('Forcefully exit the process')}
|
|
37
|
-
${ansi.green('--timeout')} ${ansi.dim('Define default timeout for all tests')}
|
|
38
|
-
${ansi.green('--retries')} ${ansi.dim('Define default retries for all tests')}
|
|
39
|
-
${ansi.green('--reporter')} ${ansi.dim('Activate one or more test reporters')}
|
|
40
|
-
${ansi.green('--failed')} ${ansi.dim('Run tests failed during the last run')}
|
|
41
|
-
${ansi.green('-h, --help')} ${ansi.dim('View help')}
|
|
42
|
-
|
|
43
|
-
${ansi.yellow('Examples:')}
|
|
44
|
-
${ansi.dim('node bin/test.js --tags="@github"')}
|
|
45
|
-
${ansi.dim('node bin/test.js --tags="~@github"')}
|
|
46
|
-
${ansi.dim('node bin/test.js --tags="@github,@slow,@integration" --match-all')}
|
|
47
|
-
${ansi.dim('node bin/test.js --force-exit')}
|
|
48
|
-
${ansi.dim('node bin/test.js --files="user"')}
|
|
49
|
-
${ansi.dim('node bin/test.js --files="functional/user"')}
|
|
50
|
-
${ansi.dim('node bin/test.js --files="unit/user"')}
|
|
51
|
-
|
|
52
|
-
${ansi.yellow('Notes:')}
|
|
53
|
-
- When groups and tests filters are applied together. We will first filter the
|
|
54
|
-
tests by group title and then apply the tests title filter.
|
|
55
|
-
- The timeout defined on test object takes precedence over the ${ansi.green('--timeout')} flag.
|
|
56
|
-
- The retries defined on test object takes precedence over the ${ansi.green('--retries')} flag.
|
|
57
|
-
- The ${ansi.green('--files')} flag checks for the file names ending with the filter substring.
|
|
58
|
-
`;
|
|
59
|
-
/**
|
|
60
|
-
* CLI Parser is used to parse the commandline argument
|
|
61
|
-
*/
|
|
62
|
-
export class CliParser {
|
|
63
|
-
/**
|
|
64
|
-
* Parses command-line arguments
|
|
65
|
-
*/
|
|
66
|
-
parse(argv) {
|
|
67
|
-
return getopts(argv, OPTIONS);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Returns the help string
|
|
71
|
-
*/
|
|
72
|
-
getHelp() {
|
|
73
|
-
return GET_HELP();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CLIArgs, Config, NormalizedConfig } from './types.js';
|
|
2
|
-
export declare const NOOP: () => void;
|
|
3
|
-
/**
|
|
4
|
-
* Config manager is used to hydrate the configuration by merging
|
|
5
|
-
* the defaults, user defined config and the command line
|
|
6
|
-
* flags.
|
|
7
|
-
*
|
|
8
|
-
* The command line flags have the upmost priority
|
|
9
|
-
*/
|
|
10
|
-
export declare class ConfigManager {
|
|
11
|
-
#private;
|
|
12
|
-
constructor(config: Config, cliArgs: CLIArgs);
|
|
13
|
-
/**
|
|
14
|
-
* Hydrates the config with user defined options and the
|
|
15
|
-
* command-line flags.
|
|
16
|
-
*/
|
|
17
|
-
hydrate(): NormalizedConfig;
|
|
18
|
-
}
|