@japa/runner 2.2.3 → 2.4.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/index.js +5 -3
- package/build/src/core/main.d.ts +17 -0
- package/build/src/core/main.js +30 -0
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -175,7 +175,7 @@ async function endTests(runner) {
|
|
|
175
175
|
function showHelp() {
|
|
176
176
|
const green = cliui_1.logger.colors.green.bind(cliui_1.logger.colors);
|
|
177
177
|
const grey = cliui_1.logger.colors.grey.bind(cliui_1.logger.colors);
|
|
178
|
-
console.log(`@japa/runner v2.
|
|
178
|
+
console.log(`@japa/runner v2.3.0
|
|
179
179
|
|
|
180
180
|
Options:
|
|
181
181
|
${green('--tests')} ${grey('Specify test titles')}
|
|
@@ -426,8 +426,9 @@ function test(title, callback) {
|
|
|
426
426
|
ensureIsConfigured('Cannot add test without configuring the test runner');
|
|
427
427
|
const testInstance = new main_1.Test(title, getContext, emitter, runnerOptions.refiner, activeGroup);
|
|
428
428
|
/**
|
|
429
|
-
* Set filename
|
|
429
|
+
* Set filename and suite
|
|
430
430
|
*/
|
|
431
|
+
testInstance.options.meta.suite = activeSuite;
|
|
431
432
|
testInstance.options.meta.fileName = recentlyImportedFile;
|
|
432
433
|
/**
|
|
433
434
|
* Define timeout on the test when exists globally
|
|
@@ -466,8 +467,9 @@ test.group = function (title, callback) {
|
|
|
466
467
|
}
|
|
467
468
|
activeGroup = new main_1.Group(title, emitter, runnerOptions.refiner);
|
|
468
469
|
/**
|
|
469
|
-
* Set filename
|
|
470
|
+
* Set filename and suite
|
|
470
471
|
*/
|
|
472
|
+
activeGroup.options.meta.suite = activeSuite;
|
|
471
473
|
activeGroup.options.meta.fileName = recentlyImportedFile;
|
|
472
474
|
/**
|
|
473
475
|
* Add group to the default suite
|
package/build/src/core/main.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { DataSetNode, Test as BaseTest, Group as BaseGroup, Suite as BaseSuite, Runner as BaseRunner, TestHooksCleanupHandler, TestContext as BaseTestContext } from '@japa/core';
|
|
2
2
|
export declare class TestContext extends BaseTestContext {
|
|
3
3
|
test: Test;
|
|
4
|
+
/**
|
|
5
|
+
* Methods to call after the test context instance
|
|
6
|
+
* is created
|
|
7
|
+
*/
|
|
8
|
+
static createdCallbacks: ((context: TestContext) => void)[];
|
|
9
|
+
/**
|
|
10
|
+
* Register a function to get notified when an instance of test
|
|
11
|
+
* context is created. The callback must be synchronous
|
|
12
|
+
*/
|
|
13
|
+
static created(callback: (context: TestContext) => void): typeof TestContext;
|
|
14
|
+
/**
|
|
15
|
+
* Register a cleanup function. Cleanup functions are called after
|
|
16
|
+
* the test finishes
|
|
17
|
+
*/
|
|
4
18
|
cleanup: (handler: TestHooksCleanupHandler<this>) => void;
|
|
5
19
|
constructor(test: Test);
|
|
6
20
|
}
|
|
@@ -10,6 +24,9 @@ export declare class Test<TestData extends DataSetNode = undefined> extends Base
|
|
|
10
24
|
export declare class Group extends BaseGroup<TestContext> {
|
|
11
25
|
}
|
|
12
26
|
export declare class Suite extends BaseSuite<TestContext> {
|
|
27
|
+
onGroup(callback: (group: Group) => void): this;
|
|
28
|
+
onTest(callback: (test: Test<any>) => void): this;
|
|
13
29
|
}
|
|
14
30
|
export declare class Runner extends BaseRunner<TestContext> {
|
|
31
|
+
onSuite(callback: (suite: Suite) => void): this;
|
|
15
32
|
}
|
package/build/src/core/main.js
CHANGED
|
@@ -11,15 +11,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.Runner = exports.Suite = exports.Group = exports.Test = exports.TestContext = void 0;
|
|
12
12
|
const core_1 = require("@japa/core");
|
|
13
13
|
class TestContext extends core_1.TestContext {
|
|
14
|
+
/**
|
|
15
|
+
* Register a function to get notified when an instance of test
|
|
16
|
+
* context is created. The callback must be synchronous
|
|
17
|
+
*/
|
|
18
|
+
static created(callback) {
|
|
19
|
+
this.createdCallbacks.push(callback);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
14
22
|
constructor(test) {
|
|
15
23
|
super();
|
|
16
24
|
this.test = test;
|
|
17
25
|
this.cleanup = (handler) => {
|
|
18
26
|
test.cleanup(handler);
|
|
19
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Invoke ready callbacks
|
|
30
|
+
*/
|
|
31
|
+
const Constructor = this.constructor;
|
|
32
|
+
Constructor.createdCallbacks.forEach((callback) => callback(this));
|
|
20
33
|
}
|
|
21
34
|
}
|
|
22
35
|
exports.TestContext = TestContext;
|
|
36
|
+
/**
|
|
37
|
+
* Methods to call after the test context instance
|
|
38
|
+
* is created
|
|
39
|
+
*/
|
|
40
|
+
TestContext.createdCallbacks = [];
|
|
23
41
|
class Test extends core_1.Test {
|
|
24
42
|
}
|
|
25
43
|
exports.Test = Test;
|
|
@@ -28,8 +46,20 @@ class Group extends core_1.Group {
|
|
|
28
46
|
}
|
|
29
47
|
exports.Group = Group;
|
|
30
48
|
class Suite extends core_1.Suite {
|
|
49
|
+
onGroup(callback) {
|
|
50
|
+
super.onGroup(callback);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
onTest(callback) {
|
|
54
|
+
super.onTest(callback);
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
31
57
|
}
|
|
32
58
|
exports.Suite = Suite;
|
|
33
59
|
class Runner extends core_1.Runner {
|
|
60
|
+
onSuite(callback) {
|
|
61
|
+
super.onSuite(callback);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
34
64
|
}
|
|
35
65
|
exports.Runner = Runner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@japa/runner",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Runner for Japa testing framework",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"japa": "^4.0.0",
|
|
50
50
|
"mrm": "^4.1.13",
|
|
51
51
|
"np": "^7.6.3",
|
|
52
|
-
"prettier": "^2.8.
|
|
52
|
+
"prettier": "^2.8.4",
|
|
53
53
|
"typescript": "^4.9.5"
|
|
54
54
|
},
|
|
55
55
|
"mrmConfig": {
|