@japa/runner 2.5.1 → 3.0.0-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/LICENSE.md +1 -1
- package/build/index.d.ts +8 -29
- package/build/index.js +93 -466
- package/build/src/cli_parser.d.ts +6 -0
- package/build/src/cli_parser.d.ts.map +1 -0
- package/build/src/cli_parser.js +49 -0
- package/build/src/config_manager.d.ts +7 -0
- package/build/src/config_manager.d.ts.map +1 -0
- package/build/src/config_manager.js +115 -0
- package/build/src/create_test.d.ts +16 -0
- package/build/src/create_test.d.ts.map +1 -0
- package/build/src/create_test.js +33 -0
- package/build/src/debug.d.ts +2 -1
- package/build/src/debug.d.ts.map +1 -0
- package/build/src/debug.js +2 -12
- package/build/src/exceptions_manager.d.ts +7 -0
- package/build/src/exceptions_manager.d.ts.map +1 -0
- package/build/src/exceptions_manager.js +58 -0
- package/build/src/files_manager.d.ts +7 -0
- package/build/src/files_manager.d.ts.map +1 -0
- package/build/src/files_manager.js +28 -0
- package/build/src/helpers.d.ts +23 -0
- package/build/src/helpers.d.ts.map +1 -0
- package/build/src/helpers.js +2 -0
- package/build/src/hooks.d.ts +9 -0
- package/build/src/hooks.d.ts.map +1 -0
- package/build/src/hooks.js +26 -0
- package/build/src/planner.d.ts +18 -0
- package/build/src/planner.d.ts.map +1 -0
- package/build/src/planner.js +67 -0
- package/build/src/plugins/retry.d.ts +8 -0
- package/build/src/plugins/retry.d.ts.map +1 -0
- package/build/src/plugins/retry.js +42 -0
- package/build/src/reporters/dot.d.ts +7 -0
- package/build/src/reporters/dot.d.ts.map +1 -0
- package/build/src/reporters/dot.js +24 -0
- package/build/src/reporters/main.d.ts +5 -0
- package/build/src/reporters/main.d.ts.map +1 -0
- package/build/src/reporters/main.js +21 -0
- package/build/src/reporters/ndjson.d.ts +12 -0
- package/build/src/reporters/ndjson.d.ts.map +1 -0
- package/build/src/reporters/ndjson.js +61 -0
- package/build/src/reporters/spec.d.ts +11 -0
- package/build/src/reporters/spec.d.ts.map +1 -0
- package/build/src/reporters/spec.js +103 -0
- package/build/src/types.d.ts +48 -49
- package/build/src/types.d.ts.map +1 -0
- package/build/src/types.js +1 -10
- package/build/src/validator.d.ts +11 -0
- package/build/src/validator.d.ts.map +1 -0
- package/build/src/validator.js +46 -0
- package/package.json +76 -83
- package/build/src/core/main.d.ts +0 -49
- package/build/src/core/main.js +0 -87
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DotReporter } from './dot.js';
|
|
2
|
+
import { SpecReporter } from './spec.js';
|
|
3
|
+
import { NdJSONReporter } from './ndjson.js';
|
|
4
|
+
export const spec = (options) => {
|
|
5
|
+
return {
|
|
6
|
+
name: 'spec',
|
|
7
|
+
handler: (...args) => new SpecReporter(options).boot(...args),
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export const dot = (options) => {
|
|
11
|
+
return {
|
|
12
|
+
name: 'dot',
|
|
13
|
+
handler: (...args) => new DotReporter(options).boot(...args),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const ndjson = (options) => {
|
|
17
|
+
return {
|
|
18
|
+
name: 'ndjson',
|
|
19
|
+
handler: (...args) => new NdJSONReporter(options).boot(...args),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseReporter } from '../../modules/core/main.js';
|
|
2
|
+
import type { TestEndNode, SuiteEndNode, GroupEndNode, SuiteStartNode, GroupStartNode } from '../../modules/core/types.js';
|
|
3
|
+
export declare class NdJSONReporter extends BaseReporter {
|
|
4
|
+
#private;
|
|
5
|
+
protected onTestEnd(payload: TestEndNode): void;
|
|
6
|
+
protected onGroupStart(payload: GroupStartNode): void;
|
|
7
|
+
protected onGroupEnd(payload: GroupEndNode): void;
|
|
8
|
+
protected onSuiteStart(payload: SuiteStartNode): void;
|
|
9
|
+
protected onSuiteEnd(payload: SuiteEndNode): void;
|
|
10
|
+
protected end(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ndjson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndjson.d.ts","sourceRoot":"","sources":["../../../src/reporters/ndjson.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACf,MAAM,6BAA6B,CAAA;AAMpC,qBAAa,cAAe,SAAQ,YAAY;;IAQ9C,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAuB/C,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IASrD,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAQjD,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IASrD,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;cASjC,GAAG;CAWpB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import { BaseReporter } from '../../modules/core/main.js';
|
|
3
|
+
export class NdJSONReporter extends BaseReporter {
|
|
4
|
+
#getRelativeFilename(fileName) {
|
|
5
|
+
return relative(process.cwd(), fileName);
|
|
6
|
+
}
|
|
7
|
+
onTestEnd(payload) {
|
|
8
|
+
console.log(JSON.stringify({
|
|
9
|
+
event: 'test:end',
|
|
10
|
+
filePath: this.currentFileName,
|
|
11
|
+
relativePath: this.currentFileName
|
|
12
|
+
? this.#getRelativeFilename(this.currentFileName)
|
|
13
|
+
: undefined,
|
|
14
|
+
title: payload.title,
|
|
15
|
+
duration: payload.duration,
|
|
16
|
+
failReason: payload.failReason,
|
|
17
|
+
isFailing: payload.isFailing,
|
|
18
|
+
skipReason: payload.skipReason,
|
|
19
|
+
isSkipped: payload.isSkipped,
|
|
20
|
+
isTodo: payload.isTodo,
|
|
21
|
+
isPinned: payload.isPinned,
|
|
22
|
+
retryAttempt: payload.retryAttempt,
|
|
23
|
+
retries: payload.retries,
|
|
24
|
+
errors: payload.errors,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
onGroupStart(payload) {
|
|
28
|
+
console.log(JSON.stringify({
|
|
29
|
+
event: 'group:start',
|
|
30
|
+
title: payload.title,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
onGroupEnd(payload) {
|
|
34
|
+
JSON.stringify({
|
|
35
|
+
event: 'group:end',
|
|
36
|
+
title: payload.title,
|
|
37
|
+
errors: payload.errors,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
onSuiteStart(payload) {
|
|
41
|
+
console.log(JSON.stringify({
|
|
42
|
+
event: 'suite:start',
|
|
43
|
+
...payload,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
onSuiteEnd(payload) {
|
|
47
|
+
console.log(JSON.stringify({
|
|
48
|
+
event: 'suite:end',
|
|
49
|
+
...payload,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async end() {
|
|
53
|
+
const summary = this.runner.getSummary();
|
|
54
|
+
console.log(JSON.stringify({
|
|
55
|
+
aggregates: summary.aggregates,
|
|
56
|
+
duration: summary.duration,
|
|
57
|
+
failedTestsTitles: summary.failedTestsTitles,
|
|
58
|
+
hasError: summary.hasError,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseReporter } from '../../modules/core/main.js';
|
|
2
|
+
import { GroupStartNode, TestEndNode } from '../../modules/core/types.js';
|
|
3
|
+
export declare class SpecReporter extends BaseReporter {
|
|
4
|
+
#private;
|
|
5
|
+
protected onTestStart(): void;
|
|
6
|
+
protected onTestEnd(payload: TestEndNode): void;
|
|
7
|
+
protected onGroupStart(payload: GroupStartNode): void;
|
|
8
|
+
protected onGroupEnd(): void;
|
|
9
|
+
protected end(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/reporters/spec.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAKzE,qBAAa,YAAa,SAAQ,YAAY;;IA8H5C,SAAS,CAAC,WAAW,IAAI,IAAI;IAc7B,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAI/C,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IASrD,SAAS,CAAC,UAAU,IAAI,IAAI;cAWZ,GAAG;CAIpB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import ms from 'ms';
|
|
2
|
+
import { relative } from 'node:path';
|
|
3
|
+
import cliui from '../helpers.js';
|
|
4
|
+
import { BaseReporter } from '../../modules/core/main.js';
|
|
5
|
+
export class SpecReporter extends BaseReporter {
|
|
6
|
+
#isFirstLoneTest = true;
|
|
7
|
+
#getTestIcon(payload) {
|
|
8
|
+
if (payload.isTodo) {
|
|
9
|
+
return cliui.colors.cyan(cliui.icons.info);
|
|
10
|
+
}
|
|
11
|
+
if (payload.isFailing) {
|
|
12
|
+
return payload.hasError
|
|
13
|
+
? cliui.colors.magenta(cliui.icons.squareSmallFilled)
|
|
14
|
+
: cliui.colors.red(cliui.icons.cross);
|
|
15
|
+
}
|
|
16
|
+
if (payload.hasError) {
|
|
17
|
+
return cliui.colors.red(cliui.icons.cross);
|
|
18
|
+
}
|
|
19
|
+
if (payload.isSkipped) {
|
|
20
|
+
return cliui.colors.yellow(cliui.icons.bullet);
|
|
21
|
+
}
|
|
22
|
+
return cliui.colors.green(cliui.icons.tick);
|
|
23
|
+
}
|
|
24
|
+
#getTestMessage(payload) {
|
|
25
|
+
const message = typeof payload.title === 'string' ? payload.title : payload.title.expanded;
|
|
26
|
+
if (payload.isTodo) {
|
|
27
|
+
return cliui.colors.blue(message);
|
|
28
|
+
}
|
|
29
|
+
if (payload.isFailing) {
|
|
30
|
+
return payload.hasError ? cliui.colors.magenta(message) : cliui.colors.red(message);
|
|
31
|
+
}
|
|
32
|
+
if (payload.hasError) {
|
|
33
|
+
return cliui.colors.red(message);
|
|
34
|
+
}
|
|
35
|
+
if (payload.isSkipped) {
|
|
36
|
+
return cliui.colors.yellow(message);
|
|
37
|
+
}
|
|
38
|
+
return cliui.colors.grey(message);
|
|
39
|
+
}
|
|
40
|
+
#getSubText(payload) {
|
|
41
|
+
if (payload.isSkipped && payload.skipReason) {
|
|
42
|
+
return cliui.colors.yellow(payload.skipReason);
|
|
43
|
+
}
|
|
44
|
+
if (!payload.isFailing) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!payload.hasError) {
|
|
48
|
+
return cliui.colors.magenta(`Test marked with ".fails()" must finish with an error`);
|
|
49
|
+
}
|
|
50
|
+
if (payload.failReason) {
|
|
51
|
+
return cliui.colors.magenta(payload.failReason);
|
|
52
|
+
}
|
|
53
|
+
const testErrorMessage = payload.errors.find((error) => error.phase === 'test');
|
|
54
|
+
if (testErrorMessage && testErrorMessage.error) {
|
|
55
|
+
return cliui.colors.magenta(testErrorMessage.error.message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
#getRelativeFilename(fileName) {
|
|
59
|
+
return relative(process.cwd(), fileName);
|
|
60
|
+
}
|
|
61
|
+
#printTest(payload) {
|
|
62
|
+
const icon = this.#getTestIcon(payload);
|
|
63
|
+
const message = this.#getTestMessage(payload);
|
|
64
|
+
const prefix = payload.isPinned ? cliui.colors.yellow('[PINNED] ') : '';
|
|
65
|
+
const indentation = this.currentFileName || this.currentGroupName ? ' ' : '';
|
|
66
|
+
const duration = cliui.colors.dim(`(${ms(payload.duration)})`);
|
|
67
|
+
const retries = payload.retryAttempt && payload.retryAttempt > 1
|
|
68
|
+
? cliui.colors.dim(`(x${payload.retryAttempt}) `)
|
|
69
|
+
: '';
|
|
70
|
+
let subText = this.#getSubText(payload);
|
|
71
|
+
subText = subText ? `\n${indentation} ${subText}` : '';
|
|
72
|
+
console.log(`${indentation}${icon} ${prefix}${retries}${message} ${duration}${subText}`);
|
|
73
|
+
}
|
|
74
|
+
#printGroup(payload) {
|
|
75
|
+
const title = this.currentSuiteName !== 'default'
|
|
76
|
+
? `${this.currentSuiteName} / ${payload.title}`
|
|
77
|
+
: payload.title;
|
|
78
|
+
const suffix = this.currentFileName
|
|
79
|
+
? cliui.colors.dim(` (${this.#getRelativeFilename(this.currentFileName)})`)
|
|
80
|
+
: '';
|
|
81
|
+
console.log(`\n${title}${suffix}`);
|
|
82
|
+
}
|
|
83
|
+
onTestStart() {
|
|
84
|
+
if (this.currentFileName && this.#isFirstLoneTest) {
|
|
85
|
+
console.log(`\n${cliui.colors.dim(this.#getRelativeFilename(this.currentFileName))}`);
|
|
86
|
+
}
|
|
87
|
+
this.#isFirstLoneTest = false;
|
|
88
|
+
}
|
|
89
|
+
onTestEnd(payload) {
|
|
90
|
+
this.#printTest(payload);
|
|
91
|
+
}
|
|
92
|
+
onGroupStart(payload) {
|
|
93
|
+
this.#isFirstLoneTest = false;
|
|
94
|
+
this.#printGroup(payload);
|
|
95
|
+
}
|
|
96
|
+
onGroupEnd() {
|
|
97
|
+
this.#isFirstLoneTest = true;
|
|
98
|
+
}
|
|
99
|
+
async end() {
|
|
100
|
+
const summary = this.runner.getSummary();
|
|
101
|
+
await this.printSummary(summary);
|
|
102
|
+
}
|
|
103
|
+
}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
/// <reference types="@types/node" resolution-mode="require"/>
|
|
2
|
+
import type { HookHandler } from '@poppinss/hooks/types';
|
|
3
|
+
import type { Emitter, Refiner, Runner, Suite } from '../modules/core/main.js';
|
|
4
|
+
import type { FilteringOptions, NamedReporterContract } from '../modules/core/types.js';
|
|
5
|
+
export * from '../modules/core/types.js';
|
|
6
|
+
export type SetupHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
|
|
7
|
+
export type SetupHookHandler = HookHandler<SetupHookState[0], SetupHookState[1]>;
|
|
8
|
+
export type TeardownHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
|
|
9
|
+
export type TeardownHookHandler = HookHandler<TeardownHookState[0], TeardownHookState[1]>;
|
|
10
|
+
export type HooksEvents = {
|
|
11
|
+
setup: SetupHookState;
|
|
12
|
+
teardown: TeardownHookState;
|
|
13
|
+
};
|
|
14
|
+
export type CLIArgs = {
|
|
15
|
+
_?: string[];
|
|
16
|
+
tags?: string | string[];
|
|
17
|
+
files?: string | string[];
|
|
18
|
+
tests?: string | string[];
|
|
19
|
+
groups?: string | string[];
|
|
20
|
+
timeout?: string;
|
|
21
|
+
retries?: string;
|
|
22
|
+
reporter?: string | string[];
|
|
23
|
+
forceExit?: boolean;
|
|
24
|
+
help?: boolean;
|
|
25
|
+
matchAll?: boolean;
|
|
26
|
+
} & Record<string, string | string[] | boolean>;
|
|
14
27
|
export type Filters = FilteringOptions & {
|
|
15
28
|
files?: string[];
|
|
16
29
|
suites?: string[];
|
|
17
30
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
TestContext: typeof TestContext;
|
|
24
|
-
Group: typeof Group;
|
|
31
|
+
export type PluginFn = (japa: {
|
|
32
|
+
config: Required<Config>;
|
|
33
|
+
cliArgs: CLIArgs;
|
|
34
|
+
runner: Runner;
|
|
35
|
+
emitter: Emitter;
|
|
25
36
|
}) => void | Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Runner hooks
|
|
28
|
-
*/
|
|
29
|
-
export type RunnerHooks = {
|
|
30
|
-
setup: RunnerHooksHandler[];
|
|
31
|
-
teardown: RunnerHooksHandler[];
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Base configuration options
|
|
35
|
-
*/
|
|
36
37
|
export type BaseConfig = {
|
|
37
|
-
cliArgs?: Record<string, any>;
|
|
38
38
|
cwd?: string;
|
|
39
39
|
timeout?: number;
|
|
40
|
-
|
|
40
|
+
retries?: number;
|
|
41
41
|
filters?: Filters;
|
|
42
42
|
configureSuite?: (suite: Suite) => void;
|
|
43
|
-
reporters?:
|
|
44
|
-
|
|
43
|
+
reporters?: {
|
|
44
|
+
activated: string[];
|
|
45
|
+
list: NamedReporterContract[];
|
|
46
|
+
};
|
|
47
|
+
plugins?: PluginFn[];
|
|
48
|
+
importer?: (filePath: URL) => void | Promise<void>;
|
|
45
49
|
refiner?: Refiner;
|
|
46
50
|
forceExit?: boolean;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export type
|
|
52
|
-
/**
|
|
53
|
-
* Type for the "config.suite" property
|
|
54
|
-
*/
|
|
55
|
-
export type ConfigSuite = {
|
|
51
|
+
setup?: SetupHookHandler[];
|
|
52
|
+
teardown?: TeardownHookHandler[];
|
|
53
|
+
};
|
|
54
|
+
export type TestFiles = string | string[] | (() => URL[] | Promise<URL[]>);
|
|
55
|
+
export type TestSuite = {
|
|
56
56
|
name: string;
|
|
57
|
-
files:
|
|
57
|
+
files: TestFiles;
|
|
58
58
|
configure?: (suite: Suite) => void;
|
|
59
59
|
timeout?: number;
|
|
60
|
+
retries?: number;
|
|
60
61
|
};
|
|
61
|
-
/**
|
|
62
|
-
* Configuration options
|
|
63
|
-
*/
|
|
64
62
|
export type Config = BaseConfig & ({
|
|
65
|
-
files:
|
|
63
|
+
files: TestFiles;
|
|
66
64
|
} | {
|
|
67
|
-
suites:
|
|
65
|
+
suites: TestSuite[];
|
|
68
66
|
});
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
package/build/src/types.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
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 });
|
|
1
|
+
export * from '../modules/core/types.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Config } from './types.js';
|
|
2
|
+
declare class Validator {
|
|
3
|
+
ensureIsConfigured(config: Required<Config> | undefined): void;
|
|
4
|
+
ensureIsInPlanningPhase(phase: 'idle' | 'planning' | 'executing'): void;
|
|
5
|
+
validateSuitesFilter(config: Required<Config>): void;
|
|
6
|
+
validateSuitesForUniqueness(config: Required<Config>): void;
|
|
7
|
+
validateActivatedReporters(config: Required<Config>): void;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: Validator;
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAMnC,cAAM,SAAS;IAIb,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS;IAWvD,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW;IAWhE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IA+B7C,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IAoBpD,0BAA0B,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;CAYpD;;AAED,wBAA8B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class Validator {
|
|
2
|
+
ensureIsConfigured(config) {
|
|
3
|
+
if (!config) {
|
|
4
|
+
throw new Error(`Cannot run tests. Make sure to call "configure" method before the "run" method`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
ensureIsInPlanningPhase(phase) {
|
|
8
|
+
if (phase !== 'planning') {
|
|
9
|
+
throw new Error(`Cannot import japa test file directly. It must be imported by calling the "japa.run" method`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
validateSuitesFilter(config) {
|
|
13
|
+
if (!config.filters.suites || !config.filters.suites.length) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!('suites' in config) || !config.suites.length) {
|
|
17
|
+
throw new Error(`Cannot apply suites filter. You have not configured any test suites`);
|
|
18
|
+
}
|
|
19
|
+
const suites = config.suites.map(({ name }) => name);
|
|
20
|
+
const unknownSuites = config.filters.suites.filter((suite) => !suites.includes(suite));
|
|
21
|
+
if (unknownSuites.length) {
|
|
22
|
+
throw new Error(`Cannot apply suites filter. "${unknownSuites[0]}" suite is not configured`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
validateSuitesForUniqueness(config) {
|
|
26
|
+
if (!('suites' in config)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const suites = new Set();
|
|
30
|
+
config.suites.forEach(({ name }) => {
|
|
31
|
+
if (suites.has(name)) {
|
|
32
|
+
throw new Error(`Duplicate suite "${name}"`);
|
|
33
|
+
}
|
|
34
|
+
suites.add(name);
|
|
35
|
+
});
|
|
36
|
+
suites.clear();
|
|
37
|
+
}
|
|
38
|
+
validateActivatedReporters(config) {
|
|
39
|
+
const reportersList = config.reporters.list.map(({ name }) => name);
|
|
40
|
+
const unknownReporters = config.reporters.activated.filter((name) => !reportersList.includes(name));
|
|
41
|
+
if (unknownReporters.length) {
|
|
42
|
+
throw new Error(`Invalid reporter "${unknownReporters[0]}". Make sure to register it first inside the "reporters.list" array`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export default new Validator();
|
package/package.json
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@japa/runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-0",
|
|
4
4
|
"description": "Runner for Japa testing framework",
|
|
5
5
|
"main": "build/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"files": [
|
|
7
8
|
"build/src",
|
|
8
9
|
"build/index.d.ts",
|
|
9
10
|
"build/index.js"
|
|
10
11
|
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.16.0"
|
|
14
|
+
},
|
|
11
15
|
"exports": {
|
|
12
|
-
".": "./build/index.js"
|
|
16
|
+
".": "./build/index.js",
|
|
17
|
+
"./types": "./build/src/types.js",
|
|
18
|
+
"./reporters": "./build/src/reporters/main.js",
|
|
19
|
+
"./factories": "./build/factories/main.js",
|
|
20
|
+
"./core": "./build/modules/core/main.js"
|
|
13
21
|
},
|
|
14
22
|
"scripts": {
|
|
15
|
-
"mrm": "mrm --preset=@adonisjs/mrm-preset",
|
|
16
23
|
"pretest": "npm run lint",
|
|
17
|
-
"test": "cross-env
|
|
18
|
-
"
|
|
24
|
+
"test": "cross-env NODE_ENV=japa:runner c8 npm run quick:test",
|
|
25
|
+
"quick:test": "glob -c \"node --enable-source-maps --loader=ts-node/esm --test\" \"tests/*.spec.ts\"",
|
|
26
|
+
"clean": "del build",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
19
28
|
"compile": "npm run lint && npm run clean && tsc",
|
|
20
29
|
"build": "npm run compile",
|
|
30
|
+
"release": "np",
|
|
21
31
|
"prepublishOnly": "npm run build",
|
|
22
32
|
"lint": "eslint . --ext=.ts",
|
|
23
33
|
"format": "prettier --write .",
|
|
24
|
-
"commit": "git-cz",
|
|
25
|
-
"release": "np --message=\"chore(release): %s\"",
|
|
26
34
|
"version": "npm run build",
|
|
27
|
-
"sync-labels": "github-label-sync --labels
|
|
35
|
+
"sync-labels": "github-label-sync --labels .github/labels.json japa/runner"
|
|
28
36
|
},
|
|
29
37
|
"keywords": [
|
|
30
38
|
"japa",
|
|
@@ -34,89 +42,42 @@
|
|
|
34
42
|
"author": "virk,japa",
|
|
35
43
|
"license": "MIT",
|
|
36
44
|
"devDependencies": {
|
|
37
|
-
"@adonisjs/
|
|
45
|
+
"@adonisjs/eslint-config": "^1.1.5",
|
|
46
|
+
"@adonisjs/prettier-config": "^1.1.5",
|
|
38
47
|
"@adonisjs/require-ts": "^2.0.13",
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
48
|
+
"@adonisjs/tsconfig": "^1.1.5",
|
|
49
|
+
"@commitlint/cli": "^17.6.6",
|
|
50
|
+
"@commitlint/config-conventional": "^17.6.6",
|
|
51
|
+
"@swc/core": "^1.3.66",
|
|
52
|
+
"@types/chai": "^4.3.5",
|
|
53
|
+
"@types/chai-subset": "^1.3.3",
|
|
54
|
+
"@types/find-cache-dir": "^3.2.1",
|
|
55
|
+
"@types/ms": "^0.7.31",
|
|
56
|
+
"@types/node": "^20.3.2",
|
|
57
|
+
"c8": "^8.0.0",
|
|
58
|
+
"chai": "^4.3.7",
|
|
59
|
+
"chai-subset": "^1.6.0",
|
|
41
60
|
"cross-env": "^7.0.3",
|
|
42
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
43
61
|
"del-cli": "^5.0.0",
|
|
44
|
-
"eslint": "^8.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
48
|
-
"github-label-sync": "^2.2.0",
|
|
62
|
+
"eslint": "^8.36.0",
|
|
63
|
+
"github-label-sync": "^2.3.1",
|
|
64
|
+
"glob": "^10.3.0",
|
|
49
65
|
"husky": "^8.0.3",
|
|
50
66
|
"japa": "^4.0.0",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^
|
|
55
|
-
},
|
|
56
|
-
"mrmConfig": {
|
|
57
|
-
"core": false,
|
|
58
|
-
"license": "MIT",
|
|
59
|
-
"services": [
|
|
60
|
-
"github-actions"
|
|
61
|
-
],
|
|
62
|
-
"minNodeVersion": "16.13.1",
|
|
63
|
-
"probotApps": [
|
|
64
|
-
"stale",
|
|
65
|
-
"lock"
|
|
66
|
-
],
|
|
67
|
-
"runGhActionsOnWindows": true
|
|
68
|
-
},
|
|
69
|
-
"eslintConfig": {
|
|
70
|
-
"extends": [
|
|
71
|
-
"plugin:adonis/typescriptPackage",
|
|
72
|
-
"prettier"
|
|
73
|
-
],
|
|
74
|
-
"plugins": [
|
|
75
|
-
"prettier"
|
|
76
|
-
],
|
|
77
|
-
"rules": {
|
|
78
|
-
"prettier/prettier": [
|
|
79
|
-
"error",
|
|
80
|
-
{
|
|
81
|
-
"endOfLine": "auto"
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
"eslintIgnore": [
|
|
87
|
-
"build"
|
|
88
|
-
],
|
|
89
|
-
"prettier": {
|
|
90
|
-
"trailingComma": "es5",
|
|
91
|
-
"semi": false,
|
|
92
|
-
"singleQuote": true,
|
|
93
|
-
"useTabs": false,
|
|
94
|
-
"quoteProps": "consistent",
|
|
95
|
-
"bracketSpacing": true,
|
|
96
|
-
"arrowParens": "always",
|
|
97
|
-
"printWidth": 100
|
|
98
|
-
},
|
|
99
|
-
"config": {
|
|
100
|
-
"commitizen": {
|
|
101
|
-
"path": "cz-conventional-changelog"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
"np": {
|
|
105
|
-
"contents": ".",
|
|
106
|
-
"anyBranch": false
|
|
67
|
+
"np": "^8.0.4",
|
|
68
|
+
"prettier": "^2.8.8",
|
|
69
|
+
"ts-node": "^10.9.1",
|
|
70
|
+
"typescript": "^5.1.3"
|
|
107
71
|
},
|
|
108
72
|
"dependencies": {
|
|
109
|
-
"@japa/core": "^
|
|
110
|
-
"@japa/errors-printer": "^
|
|
111
|
-
"@poppinss/cliui": "^
|
|
112
|
-
"@poppinss/hooks": "^
|
|
73
|
+
"@japa/core": "^8.0.0-6",
|
|
74
|
+
"@japa/errors-printer": "^3.0.0-4",
|
|
75
|
+
"@poppinss/cliui": "^6.1.1-2",
|
|
76
|
+
"@poppinss/hooks": "^7.1.1-3",
|
|
113
77
|
"fast-glob": "^3.2.12",
|
|
78
|
+
"find-cache-dir": "^4.0.0",
|
|
114
79
|
"getopts": "^2.3.0",
|
|
115
|
-
"
|
|
116
|
-
},
|
|
117
|
-
"publishConfig": {
|
|
118
|
-
"access": "public",
|
|
119
|
-
"tag": "latest"
|
|
80
|
+
"ms": "^2.1.3"
|
|
120
81
|
},
|
|
121
82
|
"directories": {
|
|
122
83
|
"test": "test"
|
|
@@ -128,5 +89,37 @@
|
|
|
128
89
|
"bugs": {
|
|
129
90
|
"url": "https://github.com/japa/runner/issues"
|
|
130
91
|
},
|
|
131
|
-
"homepage": "https://github.com/japa/runner#readme"
|
|
92
|
+
"homepage": "https://github.com/japa/runner#readme",
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"access": "public",
|
|
95
|
+
"tag": "next"
|
|
96
|
+
},
|
|
97
|
+
"np": {
|
|
98
|
+
"message": "chore(release): %s",
|
|
99
|
+
"tag": "next",
|
|
100
|
+
"branch": "main",
|
|
101
|
+
"anyBranch": false
|
|
102
|
+
},
|
|
103
|
+
"commitlint": {
|
|
104
|
+
"extends": [
|
|
105
|
+
"@commitlint/config-conventional"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"prettier": "@adonisjs/prettier-config",
|
|
109
|
+
"eslintConfig": {
|
|
110
|
+
"extends": "@adonisjs/eslint-config/package"
|
|
111
|
+
},
|
|
112
|
+
"c8": {
|
|
113
|
+
"reporter": [
|
|
114
|
+
"text",
|
|
115
|
+
"html"
|
|
116
|
+
],
|
|
117
|
+
"exclude": [
|
|
118
|
+
"tests/**",
|
|
119
|
+
"tests_helpers/**",
|
|
120
|
+
"factories/**",
|
|
121
|
+
"modules/core/**",
|
|
122
|
+
"src/reporters/**"
|
|
123
|
+
]
|
|
124
|
+
}
|
|
132
125
|
}
|