@japa/runner 2.5.0 → 2.5.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/build/index.js +11 -1
- package/build/src/core/main.d.ts +17 -0
- package/build/src/core/main.js +22 -0
- package/build/src/debug.d.ts +3 -0
- package/build/src/debug.js +12 -0
- package/package.json +4 -3
package/build/index.js
CHANGED
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "TestContext", { enumerable: true, get: function
|
|
|
27
27
|
Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return main_1.Group; } });
|
|
28
28
|
Object.defineProperty(exports, "Suite", { enumerable: true, get: function () { return main_1.Suite; } });
|
|
29
29
|
Object.defineProperty(exports, "Runner", { enumerable: true, get: function () { return main_1.Runner; } });
|
|
30
|
+
const debug_1 = __importDefault(require("./src/debug"));
|
|
30
31
|
/**
|
|
31
32
|
* Filtering layers allowed by the refiner
|
|
32
33
|
*/
|
|
@@ -156,12 +157,15 @@ async function importFiles(files) {
|
|
|
156
157
|
*/
|
|
157
158
|
async function endTests(runner) {
|
|
158
159
|
if (runnerOptions.forceExit) {
|
|
160
|
+
(0, debug_1.default)('force exiting tests after executing them');
|
|
159
161
|
await runner.end();
|
|
160
162
|
}
|
|
161
163
|
else {
|
|
164
|
+
(0, debug_1.default)('executed tests and waiting for "process.beforeExit" event');
|
|
162
165
|
return new Promise((resolve) => {
|
|
163
166
|
async function beforeExit() {
|
|
164
167
|
process.removeListener('beforeExit', beforeExit);
|
|
168
|
+
(0, debug_1.default)('received "process.beforeExit" event, ending tests');
|
|
165
169
|
await runner.end();
|
|
166
170
|
resolve();
|
|
167
171
|
}
|
|
@@ -299,13 +303,17 @@ async function run() {
|
|
|
299
303
|
* running plugins only
|
|
300
304
|
*/
|
|
301
305
|
for (let plugin of runnerOptions.plugins) {
|
|
306
|
+
(0, debug_1.default)('running plugin "%s"', plugin.name || 'anonymous');
|
|
302
307
|
await plugin(runnerOptions, runner, { Test: main_1.Test, TestContext: main_1.TestContext, Group: main_1.Group });
|
|
303
308
|
}
|
|
304
309
|
validateSuitesFilter();
|
|
305
310
|
/**
|
|
306
311
|
* Step 2: Notify runner about reporters
|
|
307
312
|
*/
|
|
308
|
-
runnerOptions.reporters.forEach((reporter) =>
|
|
313
|
+
runnerOptions.reporters.forEach((reporter) => {
|
|
314
|
+
(0, debug_1.default)('registering reporter "%s"', reporter.name || 'anonymous');
|
|
315
|
+
runner.registerReporter(reporter);
|
|
316
|
+
});
|
|
309
317
|
/**
|
|
310
318
|
* Step 3: Configure runner hooks.
|
|
311
319
|
*/
|
|
@@ -326,6 +334,7 @@ async function run() {
|
|
|
326
334
|
* as part of the default suite
|
|
327
335
|
*/
|
|
328
336
|
if ('files' in runnerOptions && runnerOptions.files.length) {
|
|
337
|
+
(0, debug_1.default)('collecting files for %O globs', runnerOptions.files);
|
|
329
338
|
/**
|
|
330
339
|
* Create a default suite for files with no suite
|
|
331
340
|
*/
|
|
@@ -353,6 +362,7 @@ async function run() {
|
|
|
353
362
|
else {
|
|
354
363
|
globalTimeout = runnerOptions.timeout;
|
|
355
364
|
}
|
|
365
|
+
(0, debug_1.default)('collecting "%s" suite files for %O globs', suite.name, suite.files);
|
|
356
366
|
const files = await collectFiles(suite.files);
|
|
357
367
|
/**
|
|
358
368
|
* Only register the suite and import files when the suite
|
package/build/src/core/main.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { DataSetNode, Test as BaseTest, Group as BaseGroup, Suite as BaseSuite, Runner as BaseRunner, TestHooksCleanupHandler, TestContext as BaseTestContext } from '@japa/core';
|
|
2
|
+
/**
|
|
3
|
+
* Runner specific test context. Here we extend the test context to register
|
|
4
|
+
* cleanup methods with the test and register hooks to get notified when
|
|
5
|
+
* a new instance of test context is created.
|
|
6
|
+
*/
|
|
2
7
|
export declare class TestContext extends BaseTestContext {
|
|
3
8
|
test: Test;
|
|
4
9
|
/**
|
|
@@ -18,15 +23,27 @@ export declare class TestContext extends BaseTestContext {
|
|
|
18
23
|
cleanup: (handler: TestHooksCleanupHandler<this>) => void;
|
|
19
24
|
constructor(test: Test);
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Runner specific Test with a fixed TestContext static type.
|
|
28
|
+
*/
|
|
21
29
|
export declare class Test<TestData extends DataSetNode = undefined> extends BaseTest<TestContext, TestData> {
|
|
22
30
|
static disposeCallbacks: never[];
|
|
23
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Runner specific Group with a fixed TestContext static type.
|
|
34
|
+
*/
|
|
24
35
|
export declare class Group extends BaseGroup<TestContext> {
|
|
25
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Runner specific Suite with a fixed TestContext static type.
|
|
39
|
+
*/
|
|
26
40
|
export declare class Suite extends BaseSuite<TestContext> {
|
|
27
41
|
onGroup(callback: (group: Group) => void): this;
|
|
28
42
|
onTest(callback: (test: Test<any>) => void): this;
|
|
29
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Runner specific tests Runner with a fixed TestContext static type.
|
|
46
|
+
*/
|
|
30
47
|
export declare class Runner extends BaseRunner<TestContext> {
|
|
31
48
|
onSuite(callback: (suite: Suite) => void): this;
|
|
32
49
|
}
|
package/build/src/core/main.js
CHANGED
|
@@ -7,15 +7,25 @@
|
|
|
7
7
|
* For the full copyright and license information, please view the LICENSE
|
|
8
8
|
* file that was distributed with this source code.
|
|
9
9
|
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
10
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
14
|
exports.Runner = exports.Suite = exports.Group = exports.Test = exports.TestContext = void 0;
|
|
12
15
|
const core_1 = require("@japa/core");
|
|
16
|
+
const debug_1 = __importDefault(require("../debug"));
|
|
17
|
+
/**
|
|
18
|
+
* Runner specific test context. Here we extend the test context to register
|
|
19
|
+
* cleanup methods with the test and register hooks to get notified when
|
|
20
|
+
* a new instance of test context is created.
|
|
21
|
+
*/
|
|
13
22
|
class TestContext extends core_1.TestContext {
|
|
14
23
|
/**
|
|
15
24
|
* Register a function to get notified when an instance of test
|
|
16
25
|
* context is created. The callback must be synchronous
|
|
17
26
|
*/
|
|
18
27
|
static created(callback) {
|
|
28
|
+
(0, debug_1.default)('registering test context created hook "%s"', callback);
|
|
19
29
|
this.createdCallbacks.push(callback);
|
|
20
30
|
return this;
|
|
21
31
|
}
|
|
@@ -38,13 +48,22 @@ exports.TestContext = TestContext;
|
|
|
38
48
|
* is created
|
|
39
49
|
*/
|
|
40
50
|
TestContext.createdCallbacks = [];
|
|
51
|
+
/**
|
|
52
|
+
* Runner specific Test with a fixed TestContext static type.
|
|
53
|
+
*/
|
|
41
54
|
class Test extends core_1.Test {
|
|
42
55
|
}
|
|
43
56
|
exports.Test = Test;
|
|
44
57
|
Test.disposeCallbacks = [];
|
|
58
|
+
/**
|
|
59
|
+
* Runner specific Group with a fixed TestContext static type.
|
|
60
|
+
*/
|
|
45
61
|
class Group extends core_1.Group {
|
|
46
62
|
}
|
|
47
63
|
exports.Group = Group;
|
|
64
|
+
/**
|
|
65
|
+
* Runner specific Suite with a fixed TestContext static type.
|
|
66
|
+
*/
|
|
48
67
|
class Suite extends core_1.Suite {
|
|
49
68
|
onGroup(callback) {
|
|
50
69
|
super.onGroup(callback);
|
|
@@ -56,6 +75,9 @@ class Suite extends core_1.Suite {
|
|
|
56
75
|
}
|
|
57
76
|
}
|
|
58
77
|
exports.Suite = Suite;
|
|
78
|
+
/**
|
|
79
|
+
* Runner specific tests Runner with a fixed TestContext static type.
|
|
80
|
+
*/
|
|
59
81
|
class Runner extends core_1.Runner {
|
|
60
82
|
onSuite(callback) {
|
|
61
83
|
super.onSuite(callback);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* @japa/runner
|
|
4
|
+
*
|
|
5
|
+
* (c) Japa.dev
|
|
6
|
+
*
|
|
7
|
+
* For the full copyright and license information, please view the LICENSE
|
|
8
|
+
* file that was distributed with this source code.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
exports.default = (0, util_1.debuglog)('japa:runner');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@japa/runner",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Runner for Japa testing framework",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"mrm": "mrm --preset=@adonisjs/mrm-preset",
|
|
16
16
|
"pretest": "npm run lint",
|
|
17
|
-
"test": "node .bin/test.js",
|
|
17
|
+
"test": "cross-env NODE_DEBUG=japa:runner node .bin/test.js",
|
|
18
18
|
"clean": "del-cli build",
|
|
19
19
|
"compile": "npm run lint && npm run clean && tsc",
|
|
20
20
|
"build": "npm run compile",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@adonisjs/require-ts": "^2.0.13",
|
|
39
39
|
"@types/node": "^18.14.0",
|
|
40
40
|
"commitizen": "^4.3.0",
|
|
41
|
+
"cross-env": "^7.0.3",
|
|
41
42
|
"cz-conventional-changelog": "^3.3.0",
|
|
42
43
|
"del-cli": "^5.0.0",
|
|
43
44
|
"eslint": "^8.33.0",
|
|
@@ -105,7 +106,7 @@
|
|
|
105
106
|
"anyBranch": false
|
|
106
107
|
},
|
|
107
108
|
"dependencies": {
|
|
108
|
-
"@japa/core": "^7.3.
|
|
109
|
+
"@japa/core": "^7.3.2",
|
|
109
110
|
"@japa/errors-printer": "^2.1.0",
|
|
110
111
|
"@poppinss/cliui": "^3.0.5",
|
|
111
112
|
"@poppinss/hooks": "^6.0.2-0",
|