@japa/runner 3.0.0-2 → 3.0.0-4
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/factories/main.d.ts +3 -1
- package/build/factories/main.js +11 -0
- package/build/factories/runner.d.ts +18 -1
- package/build/factories/runner.js +45 -0
- package/build/index.d.ts +22 -1
- package/build/index.js +95 -0
- package/build/modules/core/main.d.ts +34 -1
- package/build/modules/core/main.js +53 -0
- package/build/modules/core/reporters/base.d.ts +21 -1
- package/build/modules/core/reporters/base.js +47 -0
- package/build/modules/core/types.d.ts +0 -1
- package/build/modules/core/types.js +8 -0
- package/build/src/cli_parser.d.ts +9 -1
- package/build/src/cli_parser.js +25 -0
- package/build/src/config_manager.d.ts +11 -1
- package/build/src/config_manager.js +49 -2
- package/build/src/create_test.d.ts +6 -1
- package/build/src/create_test.js +20 -0
- package/build/src/debug.d.ts +0 -1
- package/build/src/debug.js +8 -0
- package/build/src/exceptions_manager.d.ts +13 -1
- package/build/src/exceptions_manager.js +27 -0
- package/build/src/files_manager.d.ts +12 -1
- package/build/src/files_manager.js +24 -0
- package/build/src/helpers.d.ts +0 -1
- package/build/src/helpers.js +8 -0
- package/build/src/hooks.d.ts +12 -1
- package/build/src/hooks.js +20 -0
- package/build/src/planner.d.ts +8 -1
- package/build/src/planner.js +31 -0
- package/build/src/plugins/retry.d.ts +13 -1
- package/build/src/plugins/retry.js +24 -0
- package/build/src/reporters/dot.d.ts +9 -1
- package/build/src/reporters/dot.js +17 -0
- package/build/src/reporters/main.d.ts +9 -1
- package/build/src/reporters/main.js +17 -0
- package/build/src/reporters/ndjson.d.ts +4 -1
- package/build/src/reporters/ndjson.js +15 -0
- package/build/src/reporters/spec.d.ts +3 -1
- package/build/src/reporters/spec.js +51 -0
- package/build/src/types.d.ts +91 -1
- package/build/src/types.js +8 -0
- package/build/src/validator.d.ts +20 -1
- package/build/src/validator.js +39 -0
- package/package.json +33 -33
- package/build/factories/main.d.ts.map +0 -1
- package/build/factories/runner.d.ts.map +0 -1
- package/build/modules/core/main.d.ts.map +0 -1
- package/build/modules/core/reporters/base.d.ts.map +0 -1
- package/build/modules/core/types.d.ts.map +0 -1
- package/build/src/cli_parser.d.ts.map +0 -1
- package/build/src/config_manager.d.ts.map +0 -1
- package/build/src/create_test.d.ts.map +0 -1
- package/build/src/debug.d.ts.map +0 -1
- package/build/src/exceptions_manager.d.ts.map +0 -1
- package/build/src/files_manager.d.ts.map +0 -1
- package/build/src/helpers.d.ts.map +0 -1
- package/build/src/hooks.d.ts.map +0 -1
- package/build/src/planner.d.ts.map +0 -1
- package/build/src/plugins/retry.d.ts.map +0 -1
- package/build/src/reporters/dot.d.ts.map +0 -1
- package/build/src/reporters/main.d.ts.map +0 -1
- package/build/src/reporters/ndjson.d.ts.map +0 -1
- package/build/src/reporters/spec.d.ts.map +0 -1
- package/build/src/types.d.ts.map +0 -1
- package/build/src/validator.d.ts.map +0 -1
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @japa/runner
|
|
3
|
+
*
|
|
4
|
+
* (c) Japa
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
1
9
|
import cliui from '../helpers.js';
|
|
2
10
|
import { BaseReporter } from '../../modules/core/reporters/base.js';
|
|
11
|
+
/**
|
|
12
|
+
* Minimal reporter that prints each test as an icon.
|
|
13
|
+
*/
|
|
3
14
|
export class DotReporter extends BaseReporter {
|
|
15
|
+
/**
|
|
16
|
+
* When a test ended
|
|
17
|
+
*/
|
|
4
18
|
onTestEnd(payload) {
|
|
5
19
|
let output = '';
|
|
6
20
|
if (payload.isTodo) {
|
|
@@ -17,6 +31,9 @@ export class DotReporter extends BaseReporter {
|
|
|
17
31
|
}
|
|
18
32
|
process.stdout.write(`${output}`);
|
|
19
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* When test runner ended
|
|
36
|
+
*/
|
|
20
37
|
async end() {
|
|
21
38
|
console.log('');
|
|
22
39
|
await this.printSummary(this.runner.getSummary());
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { BaseReporterOptions, NamedReporterContract } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create an instance of the spec reporter
|
|
4
|
+
*/
|
|
2
5
|
export declare const spec: (options?: BaseReporterOptions) => NamedReporterContract;
|
|
6
|
+
/**
|
|
7
|
+
* Create an instance of the dot reporter
|
|
8
|
+
*/
|
|
3
9
|
export declare const dot: (options?: BaseReporterOptions) => NamedReporterContract;
|
|
10
|
+
/**
|
|
11
|
+
* Create an instance of the ndjson reporter
|
|
12
|
+
*/
|
|
4
13
|
export declare const ndjson: (options?: BaseReporterOptions) => NamedReporterContract;
|
|
5
|
-
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1,18 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @japa/runner
|
|
3
|
+
*
|
|
4
|
+
* (c) Japa
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
1
9
|
import { DotReporter } from './dot.js';
|
|
2
10
|
import { SpecReporter } from './spec.js';
|
|
3
11
|
import { NdJSONReporter } from './ndjson.js';
|
|
12
|
+
/**
|
|
13
|
+
* Create an instance of the spec reporter
|
|
14
|
+
*/
|
|
4
15
|
export const spec = (options) => {
|
|
5
16
|
return {
|
|
6
17
|
name: 'spec',
|
|
7
18
|
handler: (...args) => new SpecReporter(options).boot(...args),
|
|
8
19
|
};
|
|
9
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Create an instance of the dot reporter
|
|
23
|
+
*/
|
|
10
24
|
export const dot = (options) => {
|
|
11
25
|
return {
|
|
12
26
|
name: 'dot',
|
|
13
27
|
handler: (...args) => new DotReporter(options).boot(...args),
|
|
14
28
|
};
|
|
15
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Create an instance of the ndjson reporter
|
|
32
|
+
*/
|
|
16
33
|
export const ndjson = (options) => {
|
|
17
34
|
return {
|
|
18
35
|
name: 'ndjson',
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { BaseReporter } from '../../modules/core/main.js';
|
|
2
2
|
import type { TestEndNode, SuiteEndNode, GroupEndNode, SuiteStartNode, GroupStartNode } from '../../modules/core/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Prints tests progress as JSON. Each event is emitted
|
|
5
|
+
* independently
|
|
6
|
+
*/
|
|
3
7
|
export declare class NdJSONReporter extends BaseReporter {
|
|
4
8
|
#private;
|
|
5
9
|
protected onTestEnd(payload: TestEndNode): void;
|
|
@@ -9,4 +13,3 @@ export declare class NdJSONReporter extends BaseReporter {
|
|
|
9
13
|
protected onSuiteEnd(payload: SuiteEndNode): void;
|
|
10
14
|
protected end(): Promise<void>;
|
|
11
15
|
}
|
|
12
|
-
//# sourceMappingURL=ndjson.d.ts.map
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @japa/runner
|
|
3
|
+
*
|
|
4
|
+
* (c) Japa
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
1
9
|
import { relative } from 'node:path';
|
|
2
10
|
import { BaseReporter } from '../../modules/core/main.js';
|
|
11
|
+
/**
|
|
12
|
+
* Prints tests progress as JSON. Each event is emitted
|
|
13
|
+
* independently
|
|
14
|
+
*/
|
|
3
15
|
export class NdJSONReporter extends BaseReporter {
|
|
16
|
+
/**
|
|
17
|
+
* Returns the filename relative from the current working dir
|
|
18
|
+
*/
|
|
4
19
|
#getRelativeFilename(fileName) {
|
|
5
20
|
return relative(process.cwd(), fileName);
|
|
6
21
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseReporter } from '../../modules/core/main.js';
|
|
2
2
|
import { GroupStartNode, TestEndNode } from '../../modules/core/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pretty prints the tests on the console
|
|
5
|
+
*/
|
|
3
6
|
export declare class SpecReporter extends BaseReporter {
|
|
4
7
|
#private;
|
|
5
8
|
protected onTestStart(): void;
|
|
@@ -8,4 +11,3 @@ export declare class SpecReporter extends BaseReporter {
|
|
|
8
11
|
protected onGroupEnd(): void;
|
|
9
12
|
protected end(): Promise<void>;
|
|
10
13
|
}
|
|
11
|
-
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @japa/runner
|
|
3
|
+
*
|
|
4
|
+
* (c) Japa
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
1
9
|
import ms from 'ms';
|
|
2
10
|
import { relative } from 'node:path';
|
|
3
11
|
import cliui from '../helpers.js';
|
|
4
12
|
import { BaseReporter } from '../../modules/core/main.js';
|
|
13
|
+
/**
|
|
14
|
+
* Pretty prints the tests on the console
|
|
15
|
+
*/
|
|
5
16
|
export class SpecReporter extends BaseReporter {
|
|
17
|
+
/**
|
|
18
|
+
* Tracking if the first event we get is for a test without any parent group
|
|
19
|
+
* We need this to decide the display style for tests without groups.
|
|
20
|
+
*/
|
|
6
21
|
#isFirstLoneTest = true;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the icon for the test
|
|
24
|
+
*/
|
|
7
25
|
#getTestIcon(payload) {
|
|
8
26
|
if (payload.isTodo) {
|
|
9
27
|
return cliui.colors.cyan(cliui.icons.info);
|
|
@@ -21,6 +39,9 @@ export class SpecReporter extends BaseReporter {
|
|
|
21
39
|
}
|
|
22
40
|
return cliui.colors.green(cliui.icons.tick);
|
|
23
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the test message
|
|
44
|
+
*/
|
|
24
45
|
#getTestMessage(payload) {
|
|
25
46
|
const message = typeof payload.title === 'string' ? payload.title : payload.title.expanded;
|
|
26
47
|
if (payload.isTodo) {
|
|
@@ -37,6 +58,9 @@ export class SpecReporter extends BaseReporter {
|
|
|
37
58
|
}
|
|
38
59
|
return cliui.colors.grey(message);
|
|
39
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the subtext message for the test
|
|
63
|
+
*/
|
|
40
64
|
#getSubText(payload) {
|
|
41
65
|
if (payload.isSkipped && payload.skipReason) {
|
|
42
66
|
return cliui.colors.yellow(payload.skipReason);
|
|
@@ -55,9 +79,15 @@ export class SpecReporter extends BaseReporter {
|
|
|
55
79
|
return cliui.colors.magenta(testErrorMessage.error.message);
|
|
56
80
|
}
|
|
57
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the filename relative from the current working dir
|
|
84
|
+
*/
|
|
58
85
|
#getRelativeFilename(fileName) {
|
|
59
86
|
return relative(process.cwd(), fileName);
|
|
60
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Prints the test details
|
|
90
|
+
*/
|
|
61
91
|
#printTest(payload) {
|
|
62
92
|
const icon = this.#getTestIcon(payload);
|
|
63
93
|
const message = this.#getTestMessage(payload);
|
|
@@ -71,6 +101,9 @@ export class SpecReporter extends BaseReporter {
|
|
|
71
101
|
subText = subText ? `\n${indentation} ${subText}` : '';
|
|
72
102
|
console.log(`${indentation}${icon} ${prefix}${retries}${message} ${duration}${subText}`);
|
|
73
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Prints the group name
|
|
106
|
+
*/
|
|
74
107
|
#printGroup(payload) {
|
|
75
108
|
const title = this.currentSuiteName !== 'default'
|
|
76
109
|
? `${this.currentSuiteName} / ${payload.title}`
|
|
@@ -81,6 +114,13 @@ export class SpecReporter extends BaseReporter {
|
|
|
81
114
|
console.log(`\n${title}${suffix}`);
|
|
82
115
|
}
|
|
83
116
|
onTestStart() {
|
|
117
|
+
/**
|
|
118
|
+
* Display the filename when
|
|
119
|
+
*
|
|
120
|
+
* - The filename exists
|
|
121
|
+
* - The test is not under a group
|
|
122
|
+
* - Test is first in a sequence
|
|
123
|
+
*/
|
|
84
124
|
if (this.currentFileName && this.#isFirstLoneTest) {
|
|
85
125
|
console.log(`\n${cliui.colors.dim(this.#getRelativeFilename(this.currentFileName))}`);
|
|
86
126
|
}
|
|
@@ -90,10 +130,21 @@ export class SpecReporter extends BaseReporter {
|
|
|
90
130
|
this.#printTest(payload);
|
|
91
131
|
}
|
|
92
132
|
onGroupStart(payload) {
|
|
133
|
+
/**
|
|
134
|
+
* When a group starts, we mark the upcoming test as NOT a
|
|
135
|
+
* lone test
|
|
136
|
+
*/
|
|
93
137
|
this.#isFirstLoneTest = false;
|
|
94
138
|
this.#printGroup(payload);
|
|
95
139
|
}
|
|
96
140
|
onGroupEnd() {
|
|
141
|
+
/**
|
|
142
|
+
* When the group ends we assume that the next test can
|
|
143
|
+
* be out of the group, hence a lone test.
|
|
144
|
+
*
|
|
145
|
+
* If this assumption is false, then the `onGroupStart` method
|
|
146
|
+
* will toggle the boolean
|
|
147
|
+
*/
|
|
97
148
|
this.#isFirstLoneTest = true;
|
|
98
149
|
}
|
|
99
150
|
async end() {
|
package/build/src/types.d.ts
CHANGED
|
@@ -3,14 +3,26 @@ import type { HookHandler } from '@poppinss/hooks/types';
|
|
|
3
3
|
import type { Emitter, Refiner, Runner, Suite } from '../modules/core/main.js';
|
|
4
4
|
import type { FilteringOptions, NamedReporterContract } from '../modules/core/types.js';
|
|
5
5
|
export * from '../modules/core/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Global setup hook
|
|
8
|
+
*/
|
|
6
9
|
export type SetupHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
|
|
7
10
|
export type SetupHookHandler = HookHandler<SetupHookState[0], SetupHookState[1]>;
|
|
11
|
+
/**
|
|
12
|
+
* Global teardown hook
|
|
13
|
+
*/
|
|
8
14
|
export type TeardownHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
|
|
9
15
|
export type TeardownHookHandler = HookHandler<TeardownHookState[0], TeardownHookState[1]>;
|
|
16
|
+
/**
|
|
17
|
+
* Global set of available hooks
|
|
18
|
+
*/
|
|
10
19
|
export type HooksEvents = {
|
|
11
20
|
setup: SetupHookState;
|
|
12
21
|
teardown: TeardownHookState;
|
|
13
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Parsed command-line arguments
|
|
25
|
+
*/
|
|
14
26
|
export type CLIArgs = {
|
|
15
27
|
_?: string[];
|
|
16
28
|
tags?: string | string[];
|
|
@@ -24,44 +36,122 @@ export type CLIArgs = {
|
|
|
24
36
|
help?: boolean;
|
|
25
37
|
matchAll?: boolean;
|
|
26
38
|
} & Record<string, string | string[] | boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Set of filters you can apply to run only specific tests
|
|
41
|
+
*/
|
|
27
42
|
export type Filters = FilteringOptions & {
|
|
28
43
|
files?: string[];
|
|
29
44
|
suites?: string[];
|
|
30
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Plugin function receives an instance of the runner,
|
|
48
|
+
* emitter, config and the hooks
|
|
49
|
+
*/
|
|
31
50
|
export type PluginFn = (japa: {
|
|
32
51
|
config: Required<Config>;
|
|
33
52
|
cliArgs: CLIArgs;
|
|
34
53
|
runner: Runner;
|
|
35
54
|
emitter: Emitter;
|
|
36
55
|
}) => void | Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Base configuration options
|
|
58
|
+
*/
|
|
37
59
|
export type BaseConfig = {
|
|
60
|
+
/**
|
|
61
|
+
* Current working directory. It is required to search for
|
|
62
|
+
* the test files
|
|
63
|
+
*/
|
|
38
64
|
cwd?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The timeout to apply on all the tests, unless overwritten explicitly
|
|
67
|
+
*/
|
|
39
68
|
timeout?: number;
|
|
69
|
+
/**
|
|
70
|
+
* The retries to apply on all the tests, unless overwritten explicitly
|
|
71
|
+
*/
|
|
40
72
|
retries?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Test filters to apply
|
|
75
|
+
*/
|
|
41
76
|
filters?: Filters;
|
|
77
|
+
/**
|
|
78
|
+
* A hook to configure suites. The callback will be called for each
|
|
79
|
+
* suite before it gets executed.
|
|
80
|
+
*/
|
|
42
81
|
configureSuite?: (suite: Suite) => void;
|
|
82
|
+
/**
|
|
83
|
+
* A collection of registered reporters. Reporters are not activated by
|
|
84
|
+
* default. Either you have to activate them using the commandline,
|
|
85
|
+
* or using the `activated` property.
|
|
86
|
+
*/
|
|
43
87
|
reporters?: {
|
|
44
88
|
activated: string[];
|
|
45
89
|
list: NamedReporterContract[];
|
|
46
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* A collection of registered plugins
|
|
93
|
+
*/
|
|
47
94
|
plugins?: PluginFn[];
|
|
95
|
+
/**
|
|
96
|
+
* A custom implementation to import test files.
|
|
97
|
+
*/
|
|
48
98
|
importer?: (filePath: URL) => void | Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Overwrite tests refiner. Check documentation for refiner
|
|
101
|
+
* usage
|
|
102
|
+
*/
|
|
49
103
|
refiner?: Refiner;
|
|
104
|
+
/**
|
|
105
|
+
* Enable/disable force exiting.
|
|
106
|
+
*/
|
|
50
107
|
forceExit?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Global hooks to execute before importing
|
|
110
|
+
* the test files
|
|
111
|
+
*/
|
|
51
112
|
setup?: SetupHookHandler[];
|
|
113
|
+
/**
|
|
114
|
+
* Global hooks to execute on teardown
|
|
115
|
+
*/
|
|
52
116
|
teardown?: TeardownHookHandler[];
|
|
53
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* A collection of test files defined as a glob or a callback
|
|
120
|
+
* function that returns an array of URLs
|
|
121
|
+
*/
|
|
54
122
|
export type TestFiles = string | string[] | (() => URL[] | Promise<URL[]>);
|
|
123
|
+
/**
|
|
124
|
+
* A test suite to register tests under a named suite
|
|
125
|
+
*/
|
|
55
126
|
export type TestSuite = {
|
|
127
|
+
/**
|
|
128
|
+
* A unique name for the suite
|
|
129
|
+
*/
|
|
56
130
|
name: string;
|
|
131
|
+
/**
|
|
132
|
+
* Collection of files associated with the suite. Files should be
|
|
133
|
+
* defined as a glob or a callback function that returns an array of URLs
|
|
134
|
+
*/
|
|
57
135
|
files: TestFiles;
|
|
136
|
+
/**
|
|
137
|
+
* A callback functon to configure the suite. The callback is invoked only
|
|
138
|
+
* when the runner is going to run the tests for the given suite.
|
|
139
|
+
*/
|
|
58
140
|
configure?: (suite: Suite) => void;
|
|
141
|
+
/**
|
|
142
|
+
* The timeout to apply on all the tests in this suite, unless overwritten explicitly
|
|
143
|
+
*/
|
|
59
144
|
timeout?: number;
|
|
145
|
+
/**
|
|
146
|
+
* The retries to apply on all the tests in this suite, unless overwritten explicitly
|
|
147
|
+
*/
|
|
60
148
|
retries?: number;
|
|
61
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* Configuration options
|
|
152
|
+
*/
|
|
62
153
|
export type Config = BaseConfig & ({
|
|
63
154
|
files: TestFiles;
|
|
64
155
|
} | {
|
|
65
156
|
suites: TestSuite[];
|
|
66
157
|
});
|
|
67
|
-
//# sourceMappingURL=types.d.ts.map
|
package/build/src/types.js
CHANGED
package/build/src/validator.d.ts
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { Config } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validator encapsulates the validations to perform before running
|
|
4
|
+
* the tests
|
|
5
|
+
*/
|
|
2
6
|
declare class Validator {
|
|
7
|
+
/**
|
|
8
|
+
* Ensures the japa is configured. Otherwise raises an exception
|
|
9
|
+
*/
|
|
3
10
|
ensureIsConfigured(config: Required<Config> | undefined): void;
|
|
11
|
+
/**
|
|
12
|
+
* Ensures the japa is in planning phase
|
|
13
|
+
*/
|
|
4
14
|
ensureIsInPlanningPhase(phase: 'idle' | 'planning' | 'executing'): void;
|
|
15
|
+
/**
|
|
16
|
+
* Ensures the suites filter uses a subset of the user configured suites.
|
|
17
|
+
*/
|
|
5
18
|
validateSuitesFilter(config: Required<Config>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Ensure there are unique suites
|
|
21
|
+
*/
|
|
6
22
|
validateSuitesForUniqueness(config: Required<Config>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Ensure the activated reporters are in the list of defined
|
|
25
|
+
* reporters
|
|
26
|
+
*/
|
|
7
27
|
validateActivatedReporters(config: Required<Config>): void;
|
|
8
28
|
}
|
|
9
29
|
declare const _default: Validator;
|
|
10
30
|
export default _default;
|
|
11
|
-
//# sourceMappingURL=validator.d.ts.map
|
package/build/src/validator.js
CHANGED
|
@@ -1,27 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @japa/runner
|
|
3
|
+
*
|
|
4
|
+
* (c) Japa
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Validator encapsulates the validations to perform before running
|
|
11
|
+
* the tests
|
|
12
|
+
*/
|
|
1
13
|
class Validator {
|
|
14
|
+
/**
|
|
15
|
+
* Ensures the japa is configured. Otherwise raises an exception
|
|
16
|
+
*/
|
|
2
17
|
ensureIsConfigured(config) {
|
|
3
18
|
if (!config) {
|
|
4
19
|
throw new Error(`Cannot run tests. Make sure to call "configure" method before the "run" method`);
|
|
5
20
|
}
|
|
6
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Ensures the japa is in planning phase
|
|
24
|
+
*/
|
|
7
25
|
ensureIsInPlanningPhase(phase) {
|
|
8
26
|
if (phase !== 'planning') {
|
|
9
27
|
throw new Error(`Cannot import japa test file directly. It must be imported by calling the "japa.run" method`);
|
|
10
28
|
}
|
|
11
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Ensures the suites filter uses a subset of the user configured suites.
|
|
32
|
+
*/
|
|
12
33
|
validateSuitesFilter(config) {
|
|
34
|
+
/**
|
|
35
|
+
* Do not perform any validation if no filters are applied
|
|
36
|
+
* in the first place
|
|
37
|
+
*/
|
|
13
38
|
if (!config.filters.suites || !config.filters.suites.length) {
|
|
14
39
|
return;
|
|
15
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Notify user they have applied the suites filter but forgot to define
|
|
43
|
+
* suites
|
|
44
|
+
*/
|
|
16
45
|
if (!('suites' in config) || !config.suites.length) {
|
|
17
46
|
throw new Error(`Cannot apply suites filter. You have not configured any test suites`);
|
|
18
47
|
}
|
|
19
48
|
const suites = config.suites.map(({ name }) => name);
|
|
49
|
+
/**
|
|
50
|
+
* Find unknown suites and report the error
|
|
51
|
+
*/
|
|
20
52
|
const unknownSuites = config.filters.suites.filter((suite) => !suites.includes(suite));
|
|
21
53
|
if (unknownSuites.length) {
|
|
22
54
|
throw new Error(`Cannot apply suites filter. "${unknownSuites[0]}" suite is not configured`);
|
|
23
55
|
}
|
|
24
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Ensure there are unique suites
|
|
59
|
+
*/
|
|
25
60
|
validateSuitesForUniqueness(config) {
|
|
26
61
|
if (!('suites' in config)) {
|
|
27
62
|
return;
|
|
@@ -35,6 +70,10 @@ class Validator {
|
|
|
35
70
|
});
|
|
36
71
|
suites.clear();
|
|
37
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Ensure the activated reporters are in the list of defined
|
|
75
|
+
* reporters
|
|
76
|
+
*/
|
|
38
77
|
validateActivatedReporters(config) {
|
|
39
78
|
const reportersList = config.reporters.list.map(({ name }) => name);
|
|
40
79
|
const unknownReporters = config.reporters.activated.filter((name) => !reportersList.includes(name));
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@japa/runner",
|
|
3
|
-
"version": "3.0.0-2",
|
|
4
3
|
"description": "Runner for Japa testing framework",
|
|
4
|
+
"version": "3.0.0-4",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18.16.0"
|
|
7
|
+
},
|
|
5
8
|
"main": "build/index.js",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"files": [
|
|
@@ -11,9 +14,6 @@
|
|
|
11
14
|
"build/index.d.ts",
|
|
12
15
|
"build/index.js"
|
|
13
16
|
],
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">=18.16.0"
|
|
16
|
-
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": "./build/index.js",
|
|
19
19
|
"./types": "./build/src/types.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"pretest": "npm run lint",
|
|
26
26
|
"test": "cross-env NODE_ENV=japa:runner c8 npm run quick:test",
|
|
27
27
|
"quick:test": "glob -c \"node --enable-source-maps --loader=ts-node/esm --test-reporter=spec --test\" \"tests/*.spec.ts\"",
|
|
28
|
-
"clean": "del build",
|
|
28
|
+
"clean": "del-cli build",
|
|
29
29
|
"typecheck": "tsc --noEmit",
|
|
30
30
|
"compile": "npm run lint && npm run clean && tsc",
|
|
31
31
|
"build": "npm run compile",
|
|
@@ -36,32 +36,25 @@
|
|
|
36
36
|
"version": "npm run build",
|
|
37
37
|
"sync-labels": "github-label-sync --labels .github/labels.json japa/runner"
|
|
38
38
|
},
|
|
39
|
-
"keywords": [
|
|
40
|
-
"japa",
|
|
41
|
-
"tests",
|
|
42
|
-
"test-runner"
|
|
43
|
-
],
|
|
44
|
-
"author": "virk,japa",
|
|
45
|
-
"license": "MIT",
|
|
46
39
|
"devDependencies": {
|
|
47
|
-
"@adonisjs/eslint-config": "^1.1.
|
|
48
|
-
"@adonisjs/prettier-config": "^1.1.
|
|
40
|
+
"@adonisjs/eslint-config": "^1.1.7",
|
|
41
|
+
"@adonisjs/prettier-config": "^1.1.7",
|
|
49
42
|
"@adonisjs/require-ts": "^2.0.13",
|
|
50
|
-
"@adonisjs/tsconfig": "^1.1.
|
|
43
|
+
"@adonisjs/tsconfig": "^1.1.7",
|
|
51
44
|
"@commitlint/cli": "^17.6.6",
|
|
52
45
|
"@commitlint/config-conventional": "^17.6.6",
|
|
53
|
-
"@swc/core": "^1.3.
|
|
46
|
+
"@swc/core": "^1.3.68",
|
|
54
47
|
"@types/chai": "^4.3.5",
|
|
55
48
|
"@types/chai-subset": "^1.3.3",
|
|
56
49
|
"@types/find-cache-dir": "^3.2.1",
|
|
57
50
|
"@types/ms": "^0.7.31",
|
|
58
|
-
"@types/node": "^20.3.
|
|
51
|
+
"@types/node": "^20.3.3",
|
|
59
52
|
"c8": "^8.0.0",
|
|
60
53
|
"chai": "^4.3.7",
|
|
61
54
|
"chai-subset": "^1.6.0",
|
|
62
55
|
"cross-env": "^7.0.3",
|
|
63
56
|
"del-cli": "^5.0.0",
|
|
64
|
-
"eslint": "^8.
|
|
57
|
+
"eslint": "^8.44.0",
|
|
65
58
|
"github-label-sync": "^2.3.1",
|
|
66
59
|
"glob": "^10.3.1",
|
|
67
60
|
"husky": "^8.0.3",
|
|
@@ -72,19 +65,19 @@
|
|
|
72
65
|
"typescript": "^5.1.6"
|
|
73
66
|
},
|
|
74
67
|
"dependencies": {
|
|
75
|
-
"@japa/core": "^8.0.0-
|
|
68
|
+
"@japa/core": "^8.0.0-8",
|
|
76
69
|
"@japa/errors-printer": "^3.0.0-4",
|
|
77
70
|
"@poppinss/cliui": "^6.1.1-2",
|
|
78
71
|
"@poppinss/hooks": "^7.1.1-3",
|
|
79
|
-
"fast-glob": "^3.
|
|
72
|
+
"fast-glob": "^3.3.0",
|
|
80
73
|
"find-cache-dir": "^4.0.0",
|
|
81
74
|
"getopts": "^2.3.0",
|
|
82
75
|
"ms": "^2.1.3",
|
|
83
76
|
"slash": "^5.1.0"
|
|
84
77
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
"author": "virk,japa",
|
|
79
|
+
"license": "MIT",
|
|
80
|
+
"homepage": "https://github.com/japa/runner#readme",
|
|
88
81
|
"repository": {
|
|
89
82
|
"type": "git",
|
|
90
83
|
"url": "git+https://github.com/japa/runner.git"
|
|
@@ -92,7 +85,23 @@
|
|
|
92
85
|
"bugs": {
|
|
93
86
|
"url": "https://github.com/japa/runner/issues"
|
|
94
87
|
},
|
|
95
|
-
"
|
|
88
|
+
"keywords": [
|
|
89
|
+
"japa",
|
|
90
|
+
"tests",
|
|
91
|
+
"test-runner"
|
|
92
|
+
],
|
|
93
|
+
"directories": {
|
|
94
|
+
"test": "test"
|
|
95
|
+
},
|
|
96
|
+
"eslintConfig": {
|
|
97
|
+
"extends": "@adonisjs/eslint-config/package"
|
|
98
|
+
},
|
|
99
|
+
"prettier": "@adonisjs/prettier-config",
|
|
100
|
+
"commitlint": {
|
|
101
|
+
"extends": [
|
|
102
|
+
"@commitlint/config-conventional"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
96
105
|
"publishConfig": {
|
|
97
106
|
"access": "public",
|
|
98
107
|
"tag": "next"
|
|
@@ -103,15 +112,6 @@
|
|
|
103
112
|
"branch": "main",
|
|
104
113
|
"anyBranch": false
|
|
105
114
|
},
|
|
106
|
-
"commitlint": {
|
|
107
|
-
"extends": [
|
|
108
|
-
"@commitlint/config-conventional"
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
|
-
"prettier": "@adonisjs/prettier-config",
|
|
112
|
-
"eslintConfig": {
|
|
113
|
-
"extends": "@adonisjs/eslint-config/package"
|
|
114
|
-
},
|
|
115
115
|
"c8": {
|
|
116
116
|
"reporter": [
|
|
117
117
|
"text",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../factories/main.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAK3C,eAAO,MAAM,MAAM,qBAA4B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../factories/runner.ts"],"names":[],"mappings":"AAeA,OAAO,EAAW,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGjD,OAAO,EAAS,KAAK,EAAU,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAOvE,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AK,CAAC,CAAC,EAAE,eAAe;cACxB,GAAG,CAAC,CAAC,EAAE,aAAa;cAKpB,YAAY,CAAC,OAAO,EAAE,aAAa;IAqBnD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;CAyCtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../modules/core/types.ts"],"names":[],"mappings":"AASA,cAAc,kBAAkB,CAAA;AAEhC,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli_parser.d.ts","sourceRoot":"","sources":["../../src/cli_parser.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAsDzC,qBAAa,SAAS;IAIpB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;IAO9B,OAAO;CAGR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config_manager.d.ts","sourceRoot":"","sources":["../../src/config_manager.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAA;AA0B1D,qBAAa,aAAa;;gBAIZ,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAsF5C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC;CAoD5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create_test.d.ts","sourceRoot":"","sources":["../../src/create_test.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAe,MAAM,yBAAyB,CAAA;AAU3F,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,mBAwBF;AAKD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,SAeF"}
|
package/build/src/debug.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":";;AAUA,wBAAsC"}
|