@japa/runner 4.3.1 → 4.4.1
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/README.md +61 -0
- package/build/create_test-CuTGNCAf.js +353 -0
- package/build/factories/create_dummy_tests.d.ts +1 -1
- package/build/factories/main.d.ts +1 -1
- package/build/factories/main.js +182 -225
- package/build/factories/runner.d.ts +1 -1
- package/build/helpers-BlHaYYTh.js +241 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +214 -260
- package/build/main-CB1nhl6c.js +336 -0
- package/build/modules/core/main.js +2 -21
- package/build/modules/core/reporters/base.d.ts +1 -1
- package/build/src/create_test.d.ts +2 -2
- package/build/src/debug.d.ts +1 -1
- package/build/src/helpers.d.ts +11 -1
- package/build/src/hooks.d.ts +1 -1
- package/build/src/plugins/disallow_pinned_tests.d.ts +9 -0
- package/build/src/plugins/main.d.ts +1 -0
- package/build/src/plugins/main.js +23 -0
- package/build/src/reporters/main.js +3 -14
- package/build/src/reporters/spec.d.ts +1 -1
- package/build/src/types.d.ts +1 -0
- package/build/src/types.js +7 -14
- package/build/src/validator.d.ts +1 -1
- package/package.json +33 -31
- package/build/chunk-2KG3PWR4.js +0 -17
- package/build/chunk-PCBL2VZP.js +0 -295
- package/build/chunk-U3BSXCEH.js +0 -347
- package/build/chunk-Y57JXJ7G.js +0 -513
package/README.md
CHANGED
|
@@ -14,6 +14,67 @@ Japa
|
|
|
14
14
|
<br />
|
|
15
15
|
<hr>
|
|
16
16
|
|
|
17
|
+
**Featured sponsors**
|
|
18
|
+
|
|
19
|
+
<table>
|
|
20
|
+
|
|
21
|
+
<tr>
|
|
22
|
+
<td>
|
|
23
|
+
|
|
24
|
+
<a href="https://route4me.com/?utm_source=adonisjs.com">
|
|
25
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/route4me.jpg" />
|
|
26
|
+
</a>
|
|
27
|
+
|
|
28
|
+
</td>
|
|
29
|
+
|
|
30
|
+
<td>
|
|
31
|
+
|
|
32
|
+
<a href="https://ezycourse.com/?utm_source=adonisjs.com">
|
|
33
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/ezycourse.jpg" />
|
|
34
|
+
</a>
|
|
35
|
+
|
|
36
|
+
</td>
|
|
37
|
+
|
|
38
|
+
</tr>
|
|
39
|
+
|
|
40
|
+
<tr>
|
|
41
|
+
|
|
42
|
+
<td>
|
|
43
|
+
|
|
44
|
+
<a href="https://meteor.software/g6h?utm_source=adonisjs.com">
|
|
45
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/galaxy.jpg" />
|
|
46
|
+
</a>
|
|
47
|
+
|
|
48
|
+
</td>
|
|
49
|
+
|
|
50
|
+
<td>
|
|
51
|
+
|
|
52
|
+
<a href="https://www.lambdatest.com/?utm_source=adonisjs.com">
|
|
53
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/lambdatest.jpg" />
|
|
54
|
+
</a>
|
|
55
|
+
|
|
56
|
+
</td>
|
|
57
|
+
|
|
58
|
+
</tr>
|
|
59
|
+
|
|
60
|
+
<tr>
|
|
61
|
+
|
|
62
|
+
<td>
|
|
63
|
+
|
|
64
|
+
<a href="https://relancer.com/?utm_source=adonisjs.com">
|
|
65
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/relancer.jpg" />
|
|
66
|
+
</a>
|
|
67
|
+
|
|
68
|
+
</td>
|
|
69
|
+
|
|
70
|
+
<td>
|
|
71
|
+
|
|
72
|
+
</td>
|
|
73
|
+
|
|
74
|
+
</tr>
|
|
75
|
+
|
|
76
|
+
</table>
|
|
77
|
+
|
|
17
78
|

|
|
18
79
|
|
|
19
80
|
[github-actions-image]: https://img.shields.io/github/actions/workflow/status/japa/runner/checks.yml?style=for-the-badge "github-actions"
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { a as Group, l as Test, o as Refiner, t as colors, u as TestContext } from "./helpers-BlHaYYTh.js";
|
|
2
|
+
import { i as spec, n as github, r as ndjson, t as dot } from "./main-CB1nhl6c.js";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { debuglog } from "node:util";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import string from "@poppinss/string";
|
|
7
|
+
import { glob } from "node:fs/promises";
|
|
8
|
+
import Hooks from "@poppinss/hooks";
|
|
9
|
+
import getopts from "getopts";
|
|
10
|
+
import { isRunningInAIAgent } from "@poppinss/utils";
|
|
11
|
+
var debug_default = debuglog("japa:runner");
|
|
12
|
+
var Validator = class {
|
|
13
|
+
ensureIsConfigured(config) {
|
|
14
|
+
if (!config) throw new Error(`Cannot run tests. Make sure to call "configure" method before the "run" method`);
|
|
15
|
+
}
|
|
16
|
+
ensureIsInPlanningPhase(phase) {
|
|
17
|
+
if (phase !== "planning") throw new Error(`Cannot import japa test file directly. It must be imported by calling the "japa.run" method`);
|
|
18
|
+
}
|
|
19
|
+
validateSuitesFilter(config) {
|
|
20
|
+
if (!config.filters.suites || !config.filters.suites.length) return;
|
|
21
|
+
if (!("suites" in config) || !config.suites.length) throw new Error(`Cannot apply suites filter. You have not configured any test suites`);
|
|
22
|
+
const suites = config.suites.map(({ name }) => name);
|
|
23
|
+
const unknownSuites = config.filters.suites.filter((suite) => !suites.includes(suite));
|
|
24
|
+
if (unknownSuites.length) throw new Error(`Cannot apply suites filter. "${unknownSuites[0]}" suite is not configured`);
|
|
25
|
+
}
|
|
26
|
+
validateSuitesForUniqueness(config) {
|
|
27
|
+
if (!("suites" in config)) return;
|
|
28
|
+
const suites = /* @__PURE__ */ new Set();
|
|
29
|
+
config.suites.forEach(({ name }) => {
|
|
30
|
+
if (suites.has(name)) throw new Error(`Duplicate suite "${name}"`);
|
|
31
|
+
suites.add(name);
|
|
32
|
+
});
|
|
33
|
+
suites.clear();
|
|
34
|
+
}
|
|
35
|
+
validateActivatedReporters(config) {
|
|
36
|
+
const reportersList = config.reporters.list.map(({ name }) => name);
|
|
37
|
+
const unknownReporters = config.reporters.activated.filter((name) => !reportersList.includes(name));
|
|
38
|
+
if (unknownReporters.length) throw new Error(`Invalid reporter "${unknownReporters[0]}". Make sure to register it first inside the "reporters.list" array`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var validator_default = new Validator();
|
|
42
|
+
const FILE_SUFFIX_EXPRESSION = /(\.spec|\.test)?\.[js|ts|jsx|tsx|mjs|mts|cjs|cts]+$/;
|
|
43
|
+
var FilesManager = class {
|
|
44
|
+
async getFiles(cwd, files, excludes) {
|
|
45
|
+
if (Array.isArray(files) || typeof files === "string") {
|
|
46
|
+
const matchingFiles = glob(files, {
|
|
47
|
+
withFileTypes: false,
|
|
48
|
+
cwd,
|
|
49
|
+
exclude: excludes
|
|
50
|
+
});
|
|
51
|
+
return (await Array.fromAsync(matchingFiles)).sort((current, next) => {
|
|
52
|
+
return current.localeCompare(next, void 0, {
|
|
53
|
+
numeric: true,
|
|
54
|
+
sensitivity: "base"
|
|
55
|
+
});
|
|
56
|
+
}).map((file) => pathToFileURL(join(cwd, file)));
|
|
57
|
+
}
|
|
58
|
+
return await files();
|
|
59
|
+
}
|
|
60
|
+
grep(files, filters) {
|
|
61
|
+
return files.filter((file) => {
|
|
62
|
+
const filename = string.toUnixSlash(file.pathname);
|
|
63
|
+
const filenameWithoutTestSuffix = filename.replace(FILE_SUFFIX_EXPRESSION, "");
|
|
64
|
+
return !!filters.find((filter) => {
|
|
65
|
+
if (filename.endsWith(filter)) return true;
|
|
66
|
+
const filterSegments = filter.split("/").reverse();
|
|
67
|
+
const fileSegments = filenameWithoutTestSuffix.split("/").reverse();
|
|
68
|
+
return filterSegments.every((segment, index) => {
|
|
69
|
+
return fileSegments[index] && (segment === "*" || fileSegments[index].endsWith(segment));
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var Planner = class {
|
|
76
|
+
#config;
|
|
77
|
+
#fileManager = new FilesManager();
|
|
78
|
+
constructor(config) {
|
|
79
|
+
validator_default.validateActivatedReporters(config);
|
|
80
|
+
validator_default.validateSuitesFilter(config);
|
|
81
|
+
validator_default.validateSuitesForUniqueness(config);
|
|
82
|
+
this.#config = config;
|
|
83
|
+
}
|
|
84
|
+
#getActivatedReporters() {
|
|
85
|
+
return this.#config.reporters.activated.map((activated) => {
|
|
86
|
+
return this.#config.reporters.list.find(({ name }) => activated === name);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async #collectFiles(files) {
|
|
90
|
+
let filesURLs = await this.#fileManager.getFiles(this.#config.cwd, files, this.#config.exclude);
|
|
91
|
+
if (this.#config.filters.files && this.#config.filters.files.length) filesURLs = this.#fileManager.grep(filesURLs, this.#config.filters.files);
|
|
92
|
+
return filesURLs;
|
|
93
|
+
}
|
|
94
|
+
async #getSuites() {
|
|
95
|
+
let suites = [];
|
|
96
|
+
let suitesFilters = this.#config.filters.suites || [];
|
|
97
|
+
if ("files" in this.#config) suites.push({
|
|
98
|
+
name: "default",
|
|
99
|
+
files: this.#config.files,
|
|
100
|
+
timeout: this.#config.timeout,
|
|
101
|
+
retries: this.#config.retries,
|
|
102
|
+
filesURLs: await this.#collectFiles(this.#config.files)
|
|
103
|
+
});
|
|
104
|
+
if ("suites" in this.#config) {
|
|
105
|
+
for (let suite of this.#config.suites) if (!suitesFilters.length || suitesFilters.includes(suite.name)) suites.push({
|
|
106
|
+
...suite,
|
|
107
|
+
filesURLs: await this.#collectFiles(suite.files)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return suites;
|
|
111
|
+
}
|
|
112
|
+
#getRefinerFilters() {
|
|
113
|
+
return Object.keys(this.#config.filters).reduce((result, layer) => {
|
|
114
|
+
if (layer === "tests" || layer === "tags" || layer === "groups") result.push({
|
|
115
|
+
layer,
|
|
116
|
+
filters: this.#config.filters[layer]
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
}, []);
|
|
120
|
+
}
|
|
121
|
+
async plan() {
|
|
122
|
+
const suites = await this.#getSuites();
|
|
123
|
+
return {
|
|
124
|
+
reporters: this.#getActivatedReporters(),
|
|
125
|
+
suites,
|
|
126
|
+
refinerFilters: this.#getRefinerFilters(),
|
|
127
|
+
config: this.#config
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var GlobalHooks = class {
|
|
132
|
+
#hooks = new Hooks();
|
|
133
|
+
#setupRunner;
|
|
134
|
+
#teardownRunner;
|
|
135
|
+
apply(config) {
|
|
136
|
+
config.setup.forEach((hook) => this.#hooks.add("setup", hook));
|
|
137
|
+
config.teardown.forEach((hook) => this.#hooks.add("teardown", hook));
|
|
138
|
+
}
|
|
139
|
+
async setup(runner) {
|
|
140
|
+
this.#setupRunner = this.#hooks.runner("setup");
|
|
141
|
+
this.#teardownRunner = this.#hooks.runner("teardown");
|
|
142
|
+
await this.#setupRunner.run(runner);
|
|
143
|
+
}
|
|
144
|
+
async teardown(error, runner) {
|
|
145
|
+
if (this.#setupRunner) await this.#setupRunner.cleanup(error, runner);
|
|
146
|
+
if (this.#teardownRunner) {
|
|
147
|
+
if (!error) await this.#teardownRunner.run(runner);
|
|
148
|
+
await this.#teardownRunner.cleanup(error, runner);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const OPTIONS = {
|
|
153
|
+
string: [
|
|
154
|
+
"tests",
|
|
155
|
+
"groups",
|
|
156
|
+
"tags",
|
|
157
|
+
"files",
|
|
158
|
+
"timeout",
|
|
159
|
+
"retries",
|
|
160
|
+
"reporters",
|
|
161
|
+
"bailLayer"
|
|
162
|
+
],
|
|
163
|
+
boolean: [
|
|
164
|
+
"help",
|
|
165
|
+
"matchAll",
|
|
166
|
+
"failed",
|
|
167
|
+
"bail",
|
|
168
|
+
"listPinned"
|
|
169
|
+
],
|
|
170
|
+
alias: {
|
|
171
|
+
forceExit: "force-exit",
|
|
172
|
+
matchAll: "match-all",
|
|
173
|
+
listPinned: "list-pinned",
|
|
174
|
+
bailLayer: "bail-layer",
|
|
175
|
+
help: "h"
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const GET_HELP = () => `
|
|
179
|
+
${colors.yellow("@japa/runner v2.3.0")}
|
|
180
|
+
|
|
181
|
+
${colors.green("--tests")} ${colors.dim("Filter tests by the test title")}
|
|
182
|
+
${colors.green("--groups")} ${colors.dim("Filter tests by the group title")}
|
|
183
|
+
${colors.green("--tags")} ${colors.dim("Filter tests by tags")}
|
|
184
|
+
${colors.green("--match-all")} ${colors.dim("Run tests that matches all the supplied tags")}
|
|
185
|
+
${colors.green("--list-pinned")} ${colors.dim("List pinned tests")}
|
|
186
|
+
${colors.green("--files")} ${colors.dim("Filter tests by the file name")}
|
|
187
|
+
${colors.green("--force-exit")} ${colors.dim("Forcefully exit the process")}
|
|
188
|
+
${colors.green("--timeout")} ${colors.dim("Define default timeout for all tests")}
|
|
189
|
+
${colors.green("--retries")} ${colors.dim("Define default retries for all tests")}
|
|
190
|
+
${colors.green("--reporters")} ${colors.dim("Activate one or more test reporters")}
|
|
191
|
+
${colors.green("--failed")} ${colors.dim("Run tests failed during the last run")}
|
|
192
|
+
${colors.green("--bail")} ${colors.dim("Exit early when a test fails")}
|
|
193
|
+
${colors.green("--bail-layer")} ${colors.dim("Specify at which layer to enable the bail mode. Can be \"group\" or \"suite\"")}
|
|
194
|
+
${colors.green("-h, --help")} ${colors.dim("View help")}
|
|
195
|
+
|
|
196
|
+
${colors.yellow("Examples:")}
|
|
197
|
+
${colors.dim("node bin/test.js --tags=\"@github\"")}
|
|
198
|
+
${colors.dim("node bin/test.js --tags=\"~@github\"")}
|
|
199
|
+
${colors.dim("node bin/test.js --tags=\"@github,@slow,@integration\" --match-all")}
|
|
200
|
+
${colors.dim("node bin/test.js --force-exit")}
|
|
201
|
+
${colors.dim("node bin/test.js --files=\"user\"")}
|
|
202
|
+
${colors.dim("node bin/test.js --files=\"functional/user\"")}
|
|
203
|
+
${colors.dim("node bin/test.js --files=\"unit/user\"")}
|
|
204
|
+
${colors.dim("node bin/test.js --failed")}
|
|
205
|
+
${colors.dim("node bin/test.js --bail")}
|
|
206
|
+
${colors.dim("node bin/test.js --bail=group")}
|
|
207
|
+
|
|
208
|
+
${colors.yellow("Notes:")}
|
|
209
|
+
- When groups and tests filters are applied together. We will first filter the
|
|
210
|
+
tests by group title and then apply the tests filter.
|
|
211
|
+
- The timeout defined on test object takes precedence over the ${colors.green("--timeout")} flag.
|
|
212
|
+
- The retries defined on test object takes precedence over the ${colors.green("--retries")} flag.
|
|
213
|
+
- The ${colors.green("--files")} flag checks for the file names ending with the filter substring.
|
|
214
|
+
- The ${colors.green("--tags")} filter runs tests that has one or more of the supplied tags.
|
|
215
|
+
- You can use the ${colors.green("--match-all")} flag to run tests that has all the supplied tags.
|
|
216
|
+
`;
|
|
217
|
+
var CliParser = class {
|
|
218
|
+
parse(argv) {
|
|
219
|
+
return getopts(argv, OPTIONS);
|
|
220
|
+
}
|
|
221
|
+
getHelp() {
|
|
222
|
+
return GET_HELP();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const NOOP = () => {};
|
|
226
|
+
const DEFAULTS = {
|
|
227
|
+
files: [],
|
|
228
|
+
timeout: 2e3,
|
|
229
|
+
retries: 0,
|
|
230
|
+
forceExit: false,
|
|
231
|
+
plugins: [],
|
|
232
|
+
reporters: {
|
|
233
|
+
activated: isRunningInAIAgent() ? ["dot"] : ["spec"].concat(process.env.GITHUB_ACTIONS === "true" ? ["github"] : []),
|
|
234
|
+
list: [
|
|
235
|
+
spec(),
|
|
236
|
+
ndjson(),
|
|
237
|
+
dot(),
|
|
238
|
+
github()
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
importer: (filePath) => import(filePath.href),
|
|
242
|
+
configureSuite: () => {}
|
|
243
|
+
};
|
|
244
|
+
var ConfigManager = class {
|
|
245
|
+
#config;
|
|
246
|
+
#cliArgs;
|
|
247
|
+
constructor(config, cliArgs) {
|
|
248
|
+
this.#config = config;
|
|
249
|
+
this.#cliArgs = cliArgs;
|
|
250
|
+
}
|
|
251
|
+
#processAsArray(value, splitByComma) {
|
|
252
|
+
return Array.isArray(value) ? value : splitByComma ? value.split(",").map((item) => item.trim()) : [value];
|
|
253
|
+
}
|
|
254
|
+
#getCLIFilters() {
|
|
255
|
+
const filters = {};
|
|
256
|
+
if (this.#cliArgs.tags) filters.tags = this.#processAsArray(this.#cliArgs.tags, true);
|
|
257
|
+
if (this.#cliArgs.tests) filters.tests = this.#processAsArray(this.#cliArgs.tests, false);
|
|
258
|
+
if (this.#cliArgs.files) filters.files = this.#processAsArray(this.#cliArgs.files, true);
|
|
259
|
+
if (this.#cliArgs.groups) filters.groups = this.#processAsArray(this.#cliArgs.groups, false);
|
|
260
|
+
if (this.#cliArgs._ && this.#cliArgs._.length) filters.suites = this.#processAsArray(this.#cliArgs._, true);
|
|
261
|
+
return filters;
|
|
262
|
+
}
|
|
263
|
+
#getCLITimeout() {
|
|
264
|
+
if (this.#cliArgs.timeout) {
|
|
265
|
+
const value = Number(this.#cliArgs.timeout);
|
|
266
|
+
if (!Number.isNaN(value)) return value;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
#getCLIRetries() {
|
|
270
|
+
if (this.#cliArgs.retries) {
|
|
271
|
+
const value = Number(this.#cliArgs.retries);
|
|
272
|
+
if (!Number.isNaN(value)) return value;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
#getCLIForceExit() {
|
|
276
|
+
if (this.#cliArgs.forceExit) return true;
|
|
277
|
+
}
|
|
278
|
+
#getCLIReporters() {
|
|
279
|
+
if (this.#cliArgs.reporters) return this.#processAsArray(this.#cliArgs.reporters, true);
|
|
280
|
+
}
|
|
281
|
+
hydrate() {
|
|
282
|
+
const cliFilters = this.#getCLIFilters();
|
|
283
|
+
const cliRetries = this.#getCLIRetries();
|
|
284
|
+
const cliTimeout = this.#getCLITimeout();
|
|
285
|
+
const cliReporters = this.#getCLIReporters();
|
|
286
|
+
const cliForceExit = this.#getCLIForceExit();
|
|
287
|
+
debug_default("filters applied using CLI flags %O", cliFilters);
|
|
288
|
+
const baseConfig = {
|
|
289
|
+
cwd: this.#config.cwd ?? process.cwd(),
|
|
290
|
+
exclude: this.#config.exclude || [
|
|
291
|
+
"node_modules/**",
|
|
292
|
+
".git/**",
|
|
293
|
+
"coverage/**"
|
|
294
|
+
],
|
|
295
|
+
filters: Object.assign({}, this.#config.filters ?? {}, cliFilters),
|
|
296
|
+
importer: this.#config.importer ?? DEFAULTS.importer,
|
|
297
|
+
refiner: this.#config.refiner ?? new Refiner(),
|
|
298
|
+
retries: cliRetries ?? this.#config.retries ?? DEFAULTS.retries,
|
|
299
|
+
timeout: cliTimeout ?? this.#config.timeout ?? DEFAULTS.timeout,
|
|
300
|
+
plugins: this.#config.plugins ?? DEFAULTS.plugins,
|
|
301
|
+
forceExit: cliForceExit ?? this.#config.forceExit ?? DEFAULTS.forceExit,
|
|
302
|
+
reporters: this.#config.reporters ? {
|
|
303
|
+
activated: this.#config.reporters.activated,
|
|
304
|
+
list: this.#config.reporters.list || DEFAULTS.reporters.list
|
|
305
|
+
} : DEFAULTS.reporters,
|
|
306
|
+
configureSuite: this.#config.configureSuite ?? DEFAULTS.configureSuite,
|
|
307
|
+
setup: this.#config.setup || [],
|
|
308
|
+
teardown: this.#config.teardown || []
|
|
309
|
+
};
|
|
310
|
+
if (cliReporters) baseConfig.reporters.activated = cliReporters;
|
|
311
|
+
if ("files" in this.#config) return {
|
|
312
|
+
files: this.#config.files,
|
|
313
|
+
...baseConfig
|
|
314
|
+
};
|
|
315
|
+
return {
|
|
316
|
+
suites: this.#config.suites.map((suite) => {
|
|
317
|
+
return {
|
|
318
|
+
name: suite.name,
|
|
319
|
+
files: suite.files,
|
|
320
|
+
timeout: cliTimeout ?? suite.timeout ?? baseConfig.timeout,
|
|
321
|
+
retries: cliRetries ?? suite.retries ?? baseConfig.retries,
|
|
322
|
+
configure: suite.configure || NOOP
|
|
323
|
+
};
|
|
324
|
+
}),
|
|
325
|
+
...baseConfig
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const contextBuilder = (testInstance) => new TestContext(testInstance);
|
|
330
|
+
function createTest(title, emitter, refiner, debuggingError, options) {
|
|
331
|
+
const testInstance = new Test(title, contextBuilder, emitter, refiner, options.group);
|
|
332
|
+
testInstance.options.meta.suite = options.suite;
|
|
333
|
+
testInstance.options.meta.group = options.group;
|
|
334
|
+
testInstance.options.meta.fileName = options.file;
|
|
335
|
+
testInstance.options.meta.abort = (message) => {
|
|
336
|
+
debuggingError.message = message;
|
|
337
|
+
throw debuggingError;
|
|
338
|
+
};
|
|
339
|
+
if (options.timeout !== void 0) testInstance.timeout(options.timeout);
|
|
340
|
+
if (options.retries !== void 0) testInstance.retry(options.retries);
|
|
341
|
+
if (options.group) options.group.add(testInstance);
|
|
342
|
+
else if (options.suite) options.suite.add(testInstance);
|
|
343
|
+
return testInstance;
|
|
344
|
+
}
|
|
345
|
+
function createTestGroup(title, emitter, refiner, options) {
|
|
346
|
+
if (options.group) throw new Error("Nested groups are not supported by Japa");
|
|
347
|
+
const group = new Group(title, emitter, refiner);
|
|
348
|
+
group.options.meta.suite = options.suite;
|
|
349
|
+
group.options.meta.fileName = options.file;
|
|
350
|
+
if (options.suite) options.suite.add(group);
|
|
351
|
+
return group;
|
|
352
|
+
}
|
|
353
|
+
export { GlobalHooks as a, debug_default as c, CliParser as i, createTestGroup as n, Planner as o, ConfigManager as r, validator_default as s, createTest as t };
|