@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
package/build/index.js
CHANGED
|
@@ -1,214 +1,249 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import {
|
|
2
|
+
CliParser,
|
|
3
|
+
ConfigManager,
|
|
4
|
+
GlobalHooks,
|
|
5
|
+
Planner,
|
|
6
|
+
createTest,
|
|
7
|
+
createTestGroup,
|
|
8
|
+
debug_default,
|
|
9
|
+
validator_default
|
|
10
|
+
} from "./chunk-W5IABAQU.js";
|
|
11
|
+
import {
|
|
12
|
+
colors
|
|
13
|
+
} from "./chunk-7THDHQFT.js";
|
|
14
|
+
import {
|
|
15
|
+
Emitter,
|
|
16
|
+
Runner,
|
|
17
|
+
Suite
|
|
18
|
+
} from "./chunk-MCOW34SG.js";
|
|
19
|
+
import "./chunk-HN4AVHWN.js";
|
|
20
|
+
|
|
21
|
+
// index.ts
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { ErrorsPrinter as ErrorsPrinter2 } from "@japa/errors-printer";
|
|
24
|
+
|
|
25
|
+
// src/plugins/retry.ts
|
|
26
|
+
import { join } from "node:path";
|
|
27
|
+
import findCacheDirectory from "find-cache-dir";
|
|
28
|
+
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
29
|
+
var CACHE_DIR = findCacheDirectory({ name: "@japa/runner" });
|
|
30
|
+
var SUMMARY_FILE = CACHE_DIR ? join(CACHE_DIR, "summary.json") : void 0;
|
|
31
|
+
async function getFailedTests() {
|
|
32
|
+
try {
|
|
33
|
+
const summary = await readFile(SUMMARY_FILE, "utf-8");
|
|
34
|
+
return JSON.parse(summary);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error.code === "ENOENT") {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
throw new Error("Unable to read failed tests cache file", { cause: error });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function cacheFailedTests(tests) {
|
|
43
|
+
await mkdir(CACHE_DIR, { recursive: true });
|
|
44
|
+
await writeFile(SUMMARY_FILE, JSON.stringify({ tests }));
|
|
45
|
+
}
|
|
46
|
+
var retryPlugin = async function retry({ config, cliArgs: cliArgs2 }) {
|
|
47
|
+
if (!SUMMARY_FILE) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
config.teardown.push(async (runner) => {
|
|
51
|
+
const summary = runner.getSummary();
|
|
52
|
+
await cacheFailedTests(summary.failedTestsTitles);
|
|
53
|
+
});
|
|
54
|
+
if (cliArgs2.failed) {
|
|
55
|
+
const { tests } = await getFailedTests();
|
|
56
|
+
if (!tests || !tests.length) {
|
|
57
|
+
console.log(colors.bgYellow().black(" No failing tests found. Running all the tests "));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
config.filters.tests = tests;
|
|
61
|
+
}
|
|
44
62
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
|
|
64
|
+
// src/exceptions_manager.ts
|
|
65
|
+
import { ErrorsPrinter } from "@japa/errors-printer";
|
|
66
|
+
var ExceptionsManager = class {
|
|
67
|
+
#exceptionsBuffer = [];
|
|
68
|
+
#rejectionsBuffer = [];
|
|
69
|
+
#state = "watching";
|
|
70
|
+
#errorsPrinter = new ErrorsPrinter({ stackLinesCount: 2, framesMaxLimit: 4 });
|
|
71
|
+
hasErrors = false;
|
|
72
|
+
/**
|
|
73
|
+
* Monitors unhandled exceptions and rejections. The exceptions
|
|
74
|
+
* are stacked in a buffer, so that we do not clutter the
|
|
75
|
+
* tests output and once the tests are over, we will
|
|
76
|
+
* print them to the console.
|
|
77
|
+
*
|
|
78
|
+
* In case the tests are completed, we will print errors as they
|
|
79
|
+
* happen.
|
|
80
|
+
*/
|
|
81
|
+
monitor() {
|
|
82
|
+
process.on("uncaughtException", async (error) => {
|
|
83
|
+
this.hasErrors = true;
|
|
84
|
+
if (this.#state === "watching") {
|
|
85
|
+
this.#exceptionsBuffer.push(error);
|
|
86
|
+
} else {
|
|
87
|
+
this.#errorsPrinter.printSectionBorder("[Unhandled Error]");
|
|
88
|
+
await this.#errorsPrinter.printError(error);
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
}
|
|
57
91
|
});
|
|
58
|
-
|
|
59
|
-
|
|
92
|
+
process.on("unhandledRejection", async (error) => {
|
|
93
|
+
this.hasErrors = true;
|
|
94
|
+
if (this.#state === "watching") {
|
|
95
|
+
this.#rejectionsBuffer.push(error);
|
|
96
|
+
} else {
|
|
97
|
+
this.#errorsPrinter.printSectionBorder("[Unhandled Rejection]");
|
|
98
|
+
await this.#errorsPrinter.printError(error);
|
|
99
|
+
process.exitCode = 1;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async flow() {
|
|
104
|
+
if (this.#state === "flowing") {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.#state = "flowing";
|
|
108
|
+
if (this.#exceptionsBuffer.length) {
|
|
109
|
+
let exceptionsCount = this.#exceptionsBuffer.length;
|
|
110
|
+
let exceptionsIndex = this.#exceptionsBuffer.length;
|
|
111
|
+
this.#errorsPrinter.printSectionHeader("Unhandled Errors");
|
|
112
|
+
for (let exception of this.#exceptionsBuffer) {
|
|
113
|
+
await this.#errorsPrinter.printError(exception);
|
|
114
|
+
this.#errorsPrinter.printSectionBorder(`[${++exceptionsIndex}/${exceptionsCount}]`);
|
|
115
|
+
}
|
|
116
|
+
this.#exceptionsBuffer = [];
|
|
117
|
+
}
|
|
118
|
+
if (this.#rejectionsBuffer.length) {
|
|
119
|
+
let rejectionsCount = this.#exceptionsBuffer.length;
|
|
120
|
+
let rejectionsIndex = this.#exceptionsBuffer.length;
|
|
121
|
+
this.#errorsPrinter.printSectionBorder("Unhandled Rejections");
|
|
122
|
+
for (let rejection of this.#rejectionsBuffer) {
|
|
123
|
+
await this.#errorsPrinter.printError(rejection);
|
|
124
|
+
this.#errorsPrinter.printSectionBorder(`[${++rejectionsIndex}/${rejectionsCount}]`);
|
|
125
|
+
}
|
|
126
|
+
this.#rejectionsBuffer = [];
|
|
60
127
|
}
|
|
61
|
-
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// index.ts
|
|
132
|
+
var emitter = new Emitter();
|
|
133
|
+
var activeTest;
|
|
134
|
+
var cliArgs = {};
|
|
135
|
+
var runnerConfig;
|
|
136
|
+
var executionPlanState = {
|
|
137
|
+
phase: "idle"
|
|
138
|
+
};
|
|
139
|
+
function test(title, callback) {
|
|
140
|
+
validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
|
|
141
|
+
const testInstance = createTest(title, emitter, runnerConfig.refiner, executionPlanState);
|
|
142
|
+
testInstance.setup((t) => {
|
|
143
|
+
activeTest = t;
|
|
144
|
+
return () => {
|
|
145
|
+
activeTest = void 0;
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
if (callback) {
|
|
149
|
+
testInstance.run(callback);
|
|
150
|
+
}
|
|
151
|
+
return testInstance;
|
|
62
152
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
153
|
+
test.group = function(title, callback) {
|
|
154
|
+
validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
|
|
155
|
+
executionPlanState.group = createTestGroup(
|
|
156
|
+
title,
|
|
157
|
+
emitter,
|
|
158
|
+
runnerConfig.refiner,
|
|
159
|
+
executionPlanState
|
|
160
|
+
);
|
|
161
|
+
callback(executionPlanState.group);
|
|
162
|
+
executionPlanState.group = void 0;
|
|
71
163
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*/
|
|
75
|
-
export function getActiveTest() {
|
|
76
|
-
return activeTest;
|
|
164
|
+
function getActiveTest() {
|
|
165
|
+
return activeTest;
|
|
77
166
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
* will be used by Japa to compute the configuration
|
|
81
|
-
*/
|
|
82
|
-
export function processCLIArgs(argv) {
|
|
83
|
-
cliArgs = new CliParser().parse(argv);
|
|
167
|
+
function processCLIArgs(argv) {
|
|
168
|
+
cliArgs = new CliParser().parse(argv);
|
|
84
169
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* call configure method before the run method.
|
|
88
|
-
*
|
|
89
|
-
* Do note: The CLI flags will overwrite the options provided
|
|
90
|
-
* to the configure method.
|
|
91
|
-
*/
|
|
92
|
-
export function configure(options) {
|
|
93
|
-
runnerConfig = new ConfigManager(options, cliArgs).hydrate();
|
|
170
|
+
function configure(options) {
|
|
171
|
+
runnerConfig = new ConfigManager(options, cliArgs).hydrate();
|
|
94
172
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
173
|
+
async function run() {
|
|
174
|
+
if (cliArgs.help) {
|
|
175
|
+
console.log(new CliParser().getHelp());
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
validator_default.ensureIsConfigured(runnerConfig);
|
|
179
|
+
executionPlanState.phase = "planning";
|
|
180
|
+
const runner = new Runner(emitter);
|
|
181
|
+
const globalHooks = new GlobalHooks();
|
|
182
|
+
const exceptionsManager = new ExceptionsManager();
|
|
183
|
+
try {
|
|
184
|
+
await retryPlugin({ config: runnerConfig, runner, emitter, cliArgs });
|
|
185
|
+
for (let plugin of runnerConfig.plugins) {
|
|
186
|
+
debug_default('executing "%s" plugin', plugin.name || "anonymous");
|
|
187
|
+
await plugin({ runner, emitter, cliArgs, config: runnerConfig });
|
|
188
|
+
}
|
|
189
|
+
const { config, reporters, suites, refinerFilters } = await new Planner(runnerConfig).plan();
|
|
190
|
+
reporters.forEach((reporter) => {
|
|
191
|
+
debug_default('registering "%s" reporter', reporter.name);
|
|
192
|
+
runner.registerReporter(reporter);
|
|
193
|
+
});
|
|
194
|
+
refinerFilters.forEach((filter) => {
|
|
195
|
+
debug_default('apply %s filters "%O" ', filter.layer, filter.filters);
|
|
196
|
+
config.refiner.add(filter.layer, filter.filters);
|
|
197
|
+
});
|
|
198
|
+
config.refiner.matchAllTags(cliArgs.matchAll ?? false);
|
|
199
|
+
runner.onSuite(config.configureSuite);
|
|
200
|
+
debug_default("executing global hooks");
|
|
201
|
+
globalHooks.apply(config);
|
|
202
|
+
await globalHooks.setup(runner);
|
|
203
|
+
for (let suite of suites) {
|
|
204
|
+
executionPlanState.suite = new Suite(suite.name, emitter, config.refiner);
|
|
205
|
+
executionPlanState.retries = suite.retries;
|
|
206
|
+
executionPlanState.timeout = suite.timeout;
|
|
207
|
+
if (typeof suite.configure === "function") {
|
|
208
|
+
suite.configure(executionPlanState.suite);
|
|
209
|
+
}
|
|
210
|
+
runner.add(executionPlanState.suite);
|
|
211
|
+
for (let fileURL of suite.filesURLs) {
|
|
212
|
+
executionPlanState.file = fileURLToPath(fileURL);
|
|
213
|
+
debug_default("importing test file %s", executionPlanState.file);
|
|
214
|
+
await config.importer(fileURL);
|
|
215
|
+
}
|
|
216
|
+
executionPlanState.suite = void 0;
|
|
106
217
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Step 1: Executing plugins before creating a plan, so that it can mutate
|
|
119
|
-
* the config
|
|
120
|
-
*/
|
|
121
|
-
for (let plugin of runnerConfig.plugins) {
|
|
122
|
-
debug('executing "%s" plugin', plugin.name || 'anonymous');
|
|
123
|
-
await plugin({ runner, emitter, cliArgs, config: runnerConfig });
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Step 2: Creating an execution plan. The output is the result of
|
|
127
|
-
* applying all the filters and validations.
|
|
128
|
-
*/
|
|
129
|
-
const { config, reporters, suites, refinerFilters } = await new Planner(runnerConfig).plan();
|
|
130
|
-
/**
|
|
131
|
-
* Step 3: Registering reporters and filters with the runner
|
|
132
|
-
*/
|
|
133
|
-
reporters.forEach((reporter) => {
|
|
134
|
-
debug('registering "%s" reporter', reporter.name);
|
|
135
|
-
runner.registerReporter(reporter);
|
|
136
|
-
});
|
|
137
|
-
refinerFilters.forEach((filter) => {
|
|
138
|
-
debug('apply %s filters "%O" ', filter.layer, filter.filters);
|
|
139
|
-
config.refiner.add(filter.layer, filter.filters);
|
|
140
|
-
});
|
|
141
|
-
config.refiner.matchAllTags(cliArgs.matchAll ?? false);
|
|
142
|
-
runner.onSuite(config.configureSuite);
|
|
143
|
-
/**
|
|
144
|
-
* Step 4: Running the setup hooks
|
|
145
|
-
*/
|
|
146
|
-
debug('executing global hooks');
|
|
147
|
-
globalHooks.apply(config);
|
|
148
|
-
await globalHooks.setup(runner);
|
|
149
|
-
/**
|
|
150
|
-
* Step 5: Register suites and import test files
|
|
151
|
-
*/
|
|
152
|
-
for (let suite of suites) {
|
|
153
|
-
/**
|
|
154
|
-
* Creating and configuring the suite
|
|
155
|
-
*/
|
|
156
|
-
executionPlanState.suite = new Suite(suite.name, emitter, config.refiner);
|
|
157
|
-
executionPlanState.retries = suite.retries;
|
|
158
|
-
executionPlanState.timeout = suite.timeout;
|
|
159
|
-
if (typeof suite.configure === 'function') {
|
|
160
|
-
suite.configure(executionPlanState.suite);
|
|
161
|
-
}
|
|
162
|
-
runner.add(executionPlanState.suite);
|
|
163
|
-
/**
|
|
164
|
-
* Importing suite files
|
|
165
|
-
*/
|
|
166
|
-
for (let fileURL of suite.filesURLs) {
|
|
167
|
-
executionPlanState.file = fileURLToPath(fileURL);
|
|
168
|
-
debug('importing test file %s', executionPlanState.file);
|
|
169
|
-
await config.importer(fileURL);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Resetting global state
|
|
173
|
-
*/
|
|
174
|
-
executionPlanState.suite = undefined;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Onto execution phase
|
|
178
|
-
*/
|
|
179
|
-
executionPlanState.phase = 'executing';
|
|
180
|
-
/**
|
|
181
|
-
* Monitor for unhandled erorrs and rejections
|
|
182
|
-
*/
|
|
183
|
-
exceptionsManager.monitor();
|
|
184
|
-
await runner.start();
|
|
185
|
-
await runner.exec();
|
|
186
|
-
await globalHooks.teardown(null, runner);
|
|
187
|
-
await runner.end();
|
|
188
|
-
/**
|
|
189
|
-
* Print unhandled errors
|
|
190
|
-
*/
|
|
191
|
-
await exceptionsManager.flow();
|
|
192
|
-
const summary = runner.getSummary();
|
|
193
|
-
if (summary.hasError || exceptionsManager.hasErrors) {
|
|
194
|
-
process.exitCode = 1;
|
|
195
|
-
}
|
|
196
|
-
if (config.forceExit) {
|
|
197
|
-
process.exit();
|
|
198
|
-
}
|
|
218
|
+
executionPlanState.phase = "executing";
|
|
219
|
+
exceptionsManager.monitor();
|
|
220
|
+
await runner.start();
|
|
221
|
+
await runner.exec();
|
|
222
|
+
await globalHooks.teardown(null, runner);
|
|
223
|
+
await runner.end();
|
|
224
|
+
await exceptionsManager.flow();
|
|
225
|
+
const summary = runner.getSummary();
|
|
226
|
+
if (summary.hasError || exceptionsManager.hasErrors) {
|
|
227
|
+
process.exitCode = 1;
|
|
199
228
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const printer = new ErrorsPrinter();
|
|
203
|
-
await printer.printError(error);
|
|
204
|
-
/**
|
|
205
|
-
* Print unhandled errors in case the code inside
|
|
206
|
-
* the try block never got triggered
|
|
207
|
-
*/
|
|
208
|
-
await exceptionsManager.flow();
|
|
209
|
-
process.exitCode = 1;
|
|
210
|
-
if (runnerConfig.forceExit) {
|
|
211
|
-
process.exit();
|
|
212
|
-
}
|
|
229
|
+
if (config.forceExit) {
|
|
230
|
+
process.exit();
|
|
213
231
|
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
await globalHooks.teardown(error, runner);
|
|
234
|
+
const printer = new ErrorsPrinter2();
|
|
235
|
+
await printer.printError(error);
|
|
236
|
+
await exceptionsManager.flow();
|
|
237
|
+
process.exitCode = 1;
|
|
238
|
+
if (runnerConfig.forceExit) {
|
|
239
|
+
process.exit();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
214
242
|
}
|
|
243
|
+
export {
|
|
244
|
+
configure,
|
|
245
|
+
getActiveTest,
|
|
246
|
+
processCLIArgs,
|
|
247
|
+
run,
|
|
248
|
+
test
|
|
249
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Emitter, TestContext as TestContext$1, Test as Test$1, Group as Group$1, Suite as Suite$1, Runner as Runner$1 } from '@japa/core';
|
|
2
|
+
import { TestStartNode, TestEndNode, GroupStartNode, GroupEndNode, SuiteStartNode, SuiteEndNode, RunnerStartNode, RunnerEndNode, RunnerSummary, DataSetNode, TestHooksCleanupHandler } from '@japa/core/types';
|
|
3
|
+
|
|
4
|
+
type BaseReporterOptions = {
|
|
5
|
+
stackLinesCount?: number;
|
|
6
|
+
framesMaxLimit?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base reporter to build custom reporters on top of
|
|
11
|
+
*/
|
|
12
|
+
declare abstract class BaseReporter {
|
|
13
|
+
#private;
|
|
14
|
+
runner?: Runner;
|
|
15
|
+
/**
|
|
16
|
+
* Path to the file for which the tests are getting executed
|
|
17
|
+
*/
|
|
18
|
+
currentFileName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Suite for which the tests are getting executed
|
|
21
|
+
*/
|
|
22
|
+
currentSuiteName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Group for which the tests are getting executed
|
|
25
|
+
*/
|
|
26
|
+
currentGroupName?: string;
|
|
27
|
+
constructor(options?: BaseReporterOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Handlers to capture events
|
|
30
|
+
*/
|
|
31
|
+
protected onTestStart(_: TestStartNode): void;
|
|
32
|
+
protected onTestEnd(_: TestEndNode): void;
|
|
33
|
+
protected onGroupStart(_: GroupStartNode): void;
|
|
34
|
+
protected onGroupEnd(_: GroupEndNode): void;
|
|
35
|
+
protected onSuiteStart(_: SuiteStartNode): void;
|
|
36
|
+
protected onSuiteEnd(_: SuiteEndNode): void;
|
|
37
|
+
protected start(_: RunnerStartNode): Promise<void>;
|
|
38
|
+
protected end(_: RunnerEndNode): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Print tests summary
|
|
41
|
+
*/
|
|
42
|
+
protected printSummary(summary: RunnerSummary): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Invoked by the tests runner when tests are about to start
|
|
45
|
+
*/
|
|
46
|
+
boot(runner: Runner, emitter: Emitter): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare module '@japa/core' {
|
|
50
|
+
interface Test<Context extends Record<any, any>, TestData extends DataSetNode = undefined> {
|
|
51
|
+
throws(message: string | RegExp, errorConstructor?: any): this;
|
|
52
|
+
}
|
|
53
|
+
interface TestContext {
|
|
54
|
+
cleanup: (cleanupCallback: TestHooksCleanupHandler<TestContext>) => void;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Test context carries context data for a given test.
|
|
60
|
+
*/
|
|
61
|
+
declare class TestContext extends TestContext$1 {
|
|
62
|
+
test: Test;
|
|
63
|
+
/**
|
|
64
|
+
* Register a cleanup function that runs after the test finishes
|
|
65
|
+
* successfully or with an error.
|
|
66
|
+
*/
|
|
67
|
+
cleanup: (cleanupCallback: TestHooksCleanupHandler<TestContext>) => void;
|
|
68
|
+
constructor(test: Test);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Test class represents an individual test and exposes API to tweak
|
|
72
|
+
* its runtime behavior.
|
|
73
|
+
*/
|
|
74
|
+
declare class Test<TestData extends DataSetNode = undefined> extends Test$1<TestContext, TestData> {
|
|
75
|
+
/**
|
|
76
|
+
* @inheritdoc
|
|
77
|
+
*/
|
|
78
|
+
static executedCallbacks: never[];
|
|
79
|
+
/**
|
|
80
|
+
* @inheritdoc
|
|
81
|
+
*/
|
|
82
|
+
static executingCallbacks: never[];
|
|
83
|
+
/**
|
|
84
|
+
* Assert the test callback throws an exception when a certain
|
|
85
|
+
* error message and optionally is an instance of a given
|
|
86
|
+
* Error class.
|
|
87
|
+
*/
|
|
88
|
+
throws(message: string | RegExp, errorConstructor?: any): this;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* TestGroup is used to bulk configure a collection of tests and
|
|
92
|
+
* define lifecycle hooks for them
|
|
93
|
+
*/
|
|
94
|
+
declare class Group extends Group$1<TestContext> {
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A suite is a collection of tests created around a given
|
|
98
|
+
* testing type. For example: A suite for unit tests, a
|
|
99
|
+
* suite for functional tests and so on.
|
|
100
|
+
*/
|
|
101
|
+
declare class Suite extends Suite$1<TestContext> {
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Runner class is used to execute the tests
|
|
105
|
+
*/
|
|
106
|
+
declare class Runner extends Runner$1<TestContext> {
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { BaseReporterOptions as B, Group as G, Runner as R, Suite as S, TestContext as T, Test as a, BaseReporter as b };
|
|
@@ -1,62 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
declare module '@japa/core' {
|
|
5
|
-
interface Test<Context extends Record<any, any>, TestData extends DataSetNode = undefined> {
|
|
6
|
-
throws(message: string | RegExp, errorConstructor?: any): this;
|
|
7
|
-
}
|
|
8
|
-
interface TestContext {
|
|
9
|
-
cleanup: (cleanupCallback: TestHooksCleanupHandler<TestContext>) => void;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export { Emitter, Refiner, BaseReporter };
|
|
13
|
-
/**
|
|
14
|
-
* Test context carries context data for a given test.
|
|
15
|
-
*/
|
|
16
|
-
export declare class TestContext extends BaseTestContext {
|
|
17
|
-
test: Test;
|
|
18
|
-
/**
|
|
19
|
-
* Register a cleanup function that runs after the test finishes
|
|
20
|
-
* successfully or with an error.
|
|
21
|
-
*/
|
|
22
|
-
cleanup: (cleanupCallback: TestHooksCleanupHandler<TestContext>) => void;
|
|
23
|
-
constructor(test: Test);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Test class represents an individual test and exposes API to tweak
|
|
27
|
-
* its runtime behavior.
|
|
28
|
-
*/
|
|
29
|
-
export declare class Test<TestData extends DataSetNode = undefined> extends BaseTest<TestContext, TestData> {
|
|
30
|
-
/**
|
|
31
|
-
* @inheritdoc
|
|
32
|
-
*/
|
|
33
|
-
static executedCallbacks: never[];
|
|
34
|
-
/**
|
|
35
|
-
* @inheritdoc
|
|
36
|
-
*/
|
|
37
|
-
static executingCallbacks: never[];
|
|
38
|
-
/**
|
|
39
|
-
* Assert the test callback throws an exception when a certain
|
|
40
|
-
* error message and optionally is an instance of a given
|
|
41
|
-
* Error class.
|
|
42
|
-
*/
|
|
43
|
-
throws(message: string | RegExp, errorConstructor?: any): this;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* TestGroup is used to bulk configure a collection of tests and
|
|
47
|
-
* define lifecycle hooks for them
|
|
48
|
-
*/
|
|
49
|
-
export declare class Group extends BaseGroup<TestContext> {
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* A suite is a collection of tests created around a given
|
|
53
|
-
* testing type. For example: A suite for unit tests, a
|
|
54
|
-
* suite for functional tests and so on.
|
|
55
|
-
*/
|
|
56
|
-
export declare class Suite extends BaseSuite<TestContext> {
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Runner class is used to execute the tests
|
|
60
|
-
*/
|
|
61
|
-
export declare class Runner extends BaseRunner<TestContext> {
|
|
62
|
-
}
|
|
1
|
+
export { Emitter, Refiner } from '@japa/core';
|
|
2
|
+
export { b as BaseReporter, G as Group, R as Runner, S as Suite, a as Test, T as TestContext } from '../../main-63126780.js';
|
|
3
|
+
import '@japa/core/types';
|