@japa/runner 4.1.0 → 4.3.0
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-CYGUHLQ7.js → chunk-PCBL2VZP.js} +2 -2
- package/build/{chunk-DPWXK7IV.js → chunk-U3BSXCEH.js} +5 -5
- package/build/{chunk-WEAHCEFK.js → chunk-Y57JXJ7G.js} +4 -4
- package/build/factories/main.js +5 -5
- package/build/index.d.ts +5 -1
- package/build/index.js +26 -12
- package/build/modules/core/main.js +1 -1
- package/build/src/reporters/main.js +2 -2
- package/package.json +21 -23
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
Runner as BaseRunner,
|
|
9
9
|
TestContext as BaseTestContext
|
|
10
10
|
} from "@japa/core";
|
|
11
|
-
import { inspect } from "
|
|
12
|
-
import { AssertionError } from "
|
|
11
|
+
import { inspect } from "util";
|
|
12
|
+
import { AssertionError } from "assert";
|
|
13
13
|
|
|
14
14
|
// modules/core/reporters/base.ts
|
|
15
15
|
import ms from "ms";
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
BaseReporter,
|
|
3
3
|
colors,
|
|
4
4
|
icons
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PCBL2VZP.js";
|
|
6
6
|
|
|
7
7
|
// src/reporters/dot.ts
|
|
8
8
|
var DotReporter = class extends BaseReporter {
|
|
@@ -35,7 +35,7 @@ var DotReporter = class extends BaseReporter {
|
|
|
35
35
|
|
|
36
36
|
// src/reporters/spec.ts
|
|
37
37
|
import ms from "ms";
|
|
38
|
-
import { relative } from "
|
|
38
|
+
import { relative } from "path";
|
|
39
39
|
var SpecReporter = class extends BaseReporter {
|
|
40
40
|
/**
|
|
41
41
|
* Tracking if the first event we get is for a test without any parent group
|
|
@@ -155,7 +155,7 @@ ${colors.dim(this.#getRelativeFilename(this.currentFileName))}`);
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
// src/reporters/ndjson.ts
|
|
158
|
-
import { relative as relative2 } from "
|
|
158
|
+
import { relative as relative2 } from "path";
|
|
159
159
|
import { serializeError } from "serialize-error";
|
|
160
160
|
var NdJSONReporter = class extends BaseReporter {
|
|
161
161
|
/**
|
|
@@ -241,8 +241,8 @@ var NdJSONReporter = class extends BaseReporter {
|
|
|
241
241
|
|
|
242
242
|
// src/reporters/github.ts
|
|
243
243
|
import slash from "slash";
|
|
244
|
-
import { relative as relative3 } from "
|
|
245
|
-
import { stripVTControlCharacters } from "
|
|
244
|
+
import { relative as relative3 } from "path";
|
|
245
|
+
import { stripVTControlCharacters } from "util";
|
|
246
246
|
import { ErrorsPrinter } from "@japa/errors-printer";
|
|
247
247
|
var GithubReporter = class extends BaseReporter {
|
|
248
248
|
/**
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
github,
|
|
4
4
|
ndjson,
|
|
5
5
|
spec
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-U3BSXCEH.js";
|
|
7
7
|
import {
|
|
8
8
|
Group,
|
|
9
9
|
Refiner,
|
|
10
10
|
Test,
|
|
11
11
|
TestContext,
|
|
12
12
|
colors
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PCBL2VZP.js";
|
|
14
14
|
|
|
15
15
|
// src/debug.ts
|
|
16
|
-
import { debuglog } from "
|
|
16
|
+
import { debuglog } from "util";
|
|
17
17
|
var debug_default = debuglog("japa:runner");
|
|
18
18
|
|
|
19
19
|
// src/validator.ts
|
|
@@ -91,7 +91,7 @@ var validator_default = new Validator();
|
|
|
91
91
|
// src/files_manager.ts
|
|
92
92
|
import slash from "slash";
|
|
93
93
|
import fastGlob from "fast-glob";
|
|
94
|
-
import { pathToFileURL } from "
|
|
94
|
+
import { pathToFileURL } from "url";
|
|
95
95
|
var FILE_SUFFIX_EXPRESSION = /(\.spec|\.test)?\.[js|ts|jsx|tsx|mjs|mts|cjs|cts]+$/;
|
|
96
96
|
var FilesManager = class {
|
|
97
97
|
/**
|
package/build/factories/main.js
CHANGED
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
Planner,
|
|
6
6
|
createTest,
|
|
7
7
|
createTestGroup
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-Y57JXJ7G.js";
|
|
9
|
+
import "../chunk-U3BSXCEH.js";
|
|
10
10
|
import {
|
|
11
11
|
Emitter,
|
|
12
12
|
Runner,
|
|
13
13
|
Suite
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-PCBL2VZP.js";
|
|
15
15
|
import "../chunk-2KG3PWR4.js";
|
|
16
16
|
|
|
17
17
|
// factories/runner.ts
|
|
18
|
-
import { fileURLToPath } from "
|
|
18
|
+
import { fileURLToPath } from "url";
|
|
19
19
|
var RunnerFactory = class {
|
|
20
20
|
#emitter = new Emitter();
|
|
21
21
|
#config;
|
|
@@ -100,7 +100,7 @@ var RunnerFactory = class {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
// factories/create_dummy_tests.ts
|
|
103
|
-
import assert from "
|
|
103
|
+
import assert from "assert";
|
|
104
104
|
function createUnitTestsSuite(emitter, refiner, file) {
|
|
105
105
|
const suite = new Suite("unit", emitter, refiner);
|
|
106
106
|
const group = createTestGroup("Maths#add", emitter, refiner, {
|
package/build/index.d.ts
CHANGED
|
@@ -8,13 +8,17 @@ type OmitFirstArg<F> = F extends [_: any, ...args: infer R] ? R : never;
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function test(title: string, callback?: TestExecutor<TestContext, undefined>): Test<undefined>;
|
|
10
10
|
export declare namespace test {
|
|
11
|
-
var group: (title: string, callback: (group: Group) => void) =>
|
|
11
|
+
var group: (title: string, callback: (group: Group) => void) => Group;
|
|
12
12
|
var macro: <T extends (test: Test, ...args: any[]) => any>(callback: T) => (...args: OmitFirstArg<Parameters<T>>) => ReturnType<T>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Get the test of currently running test
|
|
16
16
|
*/
|
|
17
17
|
export declare function getActiveTest(): Test<any> | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Get the test of currently running test or throw an error
|
|
20
|
+
*/
|
|
21
|
+
export declare function getActiveTestOrFail(): Test<any>;
|
|
18
22
|
/**
|
|
19
23
|
* Make Japa process command line arguments. Later the parsed output
|
|
20
24
|
* will be used by Japa to compute the configuration
|
package/build/index.js
CHANGED
|
@@ -7,24 +7,24 @@ import {
|
|
|
7
7
|
createTestGroup,
|
|
8
8
|
debug_default,
|
|
9
9
|
validator_default
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-Y57JXJ7G.js";
|
|
11
|
+
import "./chunk-U3BSXCEH.js";
|
|
12
12
|
import {
|
|
13
13
|
Emitter,
|
|
14
14
|
Runner,
|
|
15
15
|
Suite,
|
|
16
16
|
colors
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-PCBL2VZP.js";
|
|
18
18
|
import "./chunk-2KG3PWR4.js";
|
|
19
19
|
|
|
20
20
|
// index.ts
|
|
21
|
-
import { fileURLToPath } from "
|
|
21
|
+
import { fileURLToPath } from "url";
|
|
22
22
|
import { ErrorsPrinter as ErrorsPrinter2 } from "@japa/errors-printer";
|
|
23
23
|
|
|
24
24
|
// src/plugins/retry.ts
|
|
25
|
-
import { join } from "
|
|
25
|
+
import { join } from "path";
|
|
26
26
|
import findCacheDirectory from "find-cache-dir";
|
|
27
|
-
import { mkdir, readFile, unlink, writeFile } from "
|
|
27
|
+
import { mkdir, readFile, unlink, writeFile } from "fs/promises";
|
|
28
28
|
var CACHE_DIR = findCacheDirectory({ name: "@japa/runner" });
|
|
29
29
|
var SUMMARY_FILE = CACHE_DIR ? join(CACHE_DIR, "summary.json") : void 0;
|
|
30
30
|
async function getFailedTests() {
|
|
@@ -84,6 +84,7 @@ var ExceptionsManager = class {
|
|
|
84
84
|
*/
|
|
85
85
|
monitor() {
|
|
86
86
|
process.on("uncaughtException", async (error) => {
|
|
87
|
+
debug_default("received uncaught exception %O", error);
|
|
87
88
|
this.hasErrors = true;
|
|
88
89
|
if (this.#state === "watching") {
|
|
89
90
|
this.#exceptionsBuffer.push(error);
|
|
@@ -94,6 +95,7 @@ var ExceptionsManager = class {
|
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
process.on("unhandledRejection", async (error) => {
|
|
98
|
+
debug_default("received unhandled rejection %O", error);
|
|
97
99
|
this.hasErrors = true;
|
|
98
100
|
if (this.#state === "watching") {
|
|
99
101
|
this.#rejectionsBuffer.push(error);
|
|
@@ -156,17 +158,14 @@ function test(title, callback) {
|
|
|
156
158
|
}
|
|
157
159
|
test.group = function(title, callback) {
|
|
158
160
|
validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
emitter,
|
|
162
|
-
runnerConfig.refiner,
|
|
163
|
-
executionPlanState
|
|
164
|
-
);
|
|
161
|
+
const group = createTestGroup(title, emitter, runnerConfig.refiner, executionPlanState);
|
|
162
|
+
executionPlanState.group = group;
|
|
165
163
|
if (cliArgs.bail && cliArgs.bailLayer === "group") {
|
|
166
164
|
executionPlanState.group.bail(true);
|
|
167
165
|
}
|
|
168
166
|
callback(executionPlanState.group);
|
|
169
167
|
executionPlanState.group = void 0;
|
|
168
|
+
return group;
|
|
170
169
|
};
|
|
171
170
|
test.macro = function(callback) {
|
|
172
171
|
return (...args) => {
|
|
@@ -179,6 +178,10 @@ test.macro = function(callback) {
|
|
|
179
178
|
function getActiveTest() {
|
|
180
179
|
return activeTest;
|
|
181
180
|
}
|
|
181
|
+
function getActiveTestOrFail() {
|
|
182
|
+
if (!activeTest) throw new Error("Cannot access active test outside of a test callback");
|
|
183
|
+
return activeTest;
|
|
184
|
+
}
|
|
182
185
|
function processCLIArgs(argv) {
|
|
183
186
|
cliArgs = new CliParser().parse(argv);
|
|
184
187
|
}
|
|
@@ -219,6 +222,7 @@ async function run() {
|
|
|
219
222
|
globalHooks.apply(config);
|
|
220
223
|
await globalHooks.setup(runner);
|
|
221
224
|
for (let suite of suites) {
|
|
225
|
+
debug_default("initiating suite %s", suite.name);
|
|
222
226
|
executionPlanState.suite = new Suite(suite.name, emitter, config.refiner);
|
|
223
227
|
executionPlanState.retries = suite.retries;
|
|
224
228
|
executionPlanState.timeout = suite.timeout;
|
|
@@ -226,6 +230,7 @@ async function run() {
|
|
|
226
230
|
suite.configure(executionPlanState.suite);
|
|
227
231
|
}
|
|
228
232
|
if (cliArgs.bail && cliArgs.bailLayer === "suite") {
|
|
233
|
+
debug_default("enabling bail mode for the suite %s", suite.name);
|
|
229
234
|
executionPlanState.suite.bail(true);
|
|
230
235
|
}
|
|
231
236
|
runner.add(executionPlanState.suite);
|
|
@@ -245,18 +250,26 @@ async function run() {
|
|
|
245
250
|
await exceptionsManager.report();
|
|
246
251
|
const summary = runner.getSummary();
|
|
247
252
|
if (summary.hasError || exceptionsManager.hasErrors) {
|
|
253
|
+
debug_default(
|
|
254
|
+
"updating exit code to 1. summary.hasError %s, process.hasError",
|
|
255
|
+
summary.hasError,
|
|
256
|
+
exceptionsManager.hasErrors
|
|
257
|
+
);
|
|
248
258
|
process.exitCode = 1;
|
|
249
259
|
}
|
|
250
260
|
if (config.forceExit) {
|
|
261
|
+
debug_default("force exiting process");
|
|
251
262
|
process.exit();
|
|
252
263
|
}
|
|
253
264
|
} catch (error) {
|
|
265
|
+
debug_default("error running tests %O", error);
|
|
254
266
|
await globalHooks.teardown(error, runner);
|
|
255
267
|
const printer = new ErrorsPrinter2();
|
|
256
268
|
await printer.printError(error);
|
|
257
269
|
await exceptionsManager.report();
|
|
258
270
|
process.exitCode = 1;
|
|
259
271
|
if (runnerConfig.forceExit) {
|
|
272
|
+
debug_default("force exiting process");
|
|
260
273
|
process.exit();
|
|
261
274
|
}
|
|
262
275
|
}
|
|
@@ -264,6 +277,7 @@ async function run() {
|
|
|
264
277
|
export {
|
|
265
278
|
configure,
|
|
266
279
|
getActiveTest,
|
|
280
|
+
getActiveTestOrFail,
|
|
267
281
|
processCLIArgs,
|
|
268
282
|
run,
|
|
269
283
|
test
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@japa/runner",
|
|
3
3
|
"description": "A simple yet powerful testing framework for Node.js",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -35,36 +35,34 @@
|
|
|
35
35
|
"quick:test": "glob -c \"node --import=ts-node-maintained/register/esm --enable-source-maps --test-reporter=spec --test\" \"tests/*.spec.ts\""
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@adonisjs/eslint-config": "^2.
|
|
39
|
-
"@adonisjs/prettier-config": "^1.4.
|
|
40
|
-
"@adonisjs/tsconfig": "^1.4.
|
|
41
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
42
|
-
"@swc/core": "
|
|
43
|
-
"@types/chai": "^5.
|
|
44
|
-
"@types/chai-subset": "^1.3.5",
|
|
38
|
+
"@adonisjs/eslint-config": "^2.1.0",
|
|
39
|
+
"@adonisjs/prettier-config": "^1.4.5",
|
|
40
|
+
"@adonisjs/tsconfig": "^1.4.1",
|
|
41
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
42
|
+
"@swc/core": "1.13.1",
|
|
43
|
+
"@types/chai": "^5.2.2",
|
|
45
44
|
"@types/find-cache-dir": "^5.0.2",
|
|
46
|
-
"@types/ms": "^
|
|
47
|
-
"@types/node": "^
|
|
45
|
+
"@types/ms": "^2.1.0",
|
|
46
|
+
"@types/node": "^24.0.15",
|
|
48
47
|
"c8": "^10.1.3",
|
|
49
|
-
"chai": "^5.1
|
|
50
|
-
"chai-subset": "^1.6.0",
|
|
48
|
+
"chai": "^5.2.1",
|
|
51
49
|
"cross-env": "^7.0.3",
|
|
52
50
|
"del-cli": "^6.0.0",
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"glob": "^11.0.
|
|
55
|
-
"prettier": "^3.
|
|
56
|
-
"release-it": "^
|
|
57
|
-
"ts-node-maintained": "^10.9.
|
|
58
|
-
"tsup": "^8.
|
|
59
|
-
"typescript": "^5.
|
|
51
|
+
"eslint": "^9.31.0",
|
|
52
|
+
"glob": "^11.0.3",
|
|
53
|
+
"prettier": "^3.6.2",
|
|
54
|
+
"release-it": "^19.0.4",
|
|
55
|
+
"ts-node-maintained": "^10.9.5",
|
|
56
|
+
"tsup": "^8.5.0",
|
|
57
|
+
"typescript": "^5.8.3"
|
|
60
58
|
},
|
|
61
59
|
"dependencies": {
|
|
62
60
|
"@japa/core": "^10.3.0",
|
|
63
|
-
"@japa/errors-printer": "^4.1.
|
|
64
|
-
"@poppinss/colors": "^4.1.
|
|
65
|
-
"@poppinss/hooks": "^7.2.
|
|
61
|
+
"@japa/errors-printer": "^4.1.2",
|
|
62
|
+
"@poppinss/colors": "^4.1.5",
|
|
63
|
+
"@poppinss/hooks": "^7.2.6",
|
|
66
64
|
"fast-glob": "^3.3.3",
|
|
67
|
-
"find-cache-dir": "^
|
|
65
|
+
"find-cache-dir": "^6.0.0",
|
|
68
66
|
"getopts": "^2.3.0",
|
|
69
67
|
"ms": "^2.1.3",
|
|
70
68
|
"serialize-error": "^12.0.0",
|