@japa/runner 3.0.0-3 → 3.0.0-5
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/src/cli_parser.js +3 -2
- package/build/src/config_manager.d.ts +3 -2
- package/build/src/config_manager.js +10 -4
- package/build/src/hooks.d.ts +2 -2
- package/build/src/planner.d.ts +3 -3
- package/build/src/plugins/retry.d.ts +1 -1
- package/build/src/plugins/retry.js +2 -2
- package/build/src/types.d.ts +20 -2
- package/build/src/validator.d.ts +5 -5
- package/package.json +29 -29
package/build/src/cli_parser.js
CHANGED
|
@@ -15,8 +15,8 @@ const ansi = colors.ansi();
|
|
|
15
15
|
* will be parsed aswell, but without any normalization
|
|
16
16
|
*/
|
|
17
17
|
const OPTIONS = {
|
|
18
|
-
string: ['tests', 'groups', 'tags', 'files', 'timeout', 'retries', 'reporter'],
|
|
19
|
-
boolean: ['help', 'matchAll'],
|
|
18
|
+
string: ['tests', 'groups', 'tags', 'files', 'timeout', 'retries', 'reporter', 'failed'],
|
|
19
|
+
boolean: ['help', 'matchAll', 'failed'],
|
|
20
20
|
alias: {
|
|
21
21
|
forceExit: 'force-exit',
|
|
22
22
|
matchAll: 'match-all',
|
|
@@ -37,6 +37,7 @@ ${ansi.green('--force-exit')} ${ansi.dim('Forcefully exit the pro
|
|
|
37
37
|
${ansi.green('--timeout')} ${ansi.dim('Define default timeout for all tests')}
|
|
38
38
|
${ansi.green('--retries')} ${ansi.dim('Define default retries for all tests')}
|
|
39
39
|
${ansi.green('--reporter')} ${ansi.dim('Activate one or more test reporters')}
|
|
40
|
+
${ansi.green('--failed')} ${ansi.dim('Run tests failed during the last run')}
|
|
40
41
|
${ansi.green('-h, --help')} ${ansi.dim('View help')}
|
|
41
42
|
|
|
42
43
|
${ansi.yellow('Examples:')}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { CLIArgs, Config } from './types.js';
|
|
1
|
+
import type { CLIArgs, Config, NormalizedConfig } from './types.js';
|
|
2
|
+
export declare const NOOP: () => void;
|
|
2
3
|
/**
|
|
3
4
|
* Config manager is used to hydrate the configuration by merging
|
|
4
5
|
* the defaults, user defined config and the command line
|
|
@@ -13,5 +14,5 @@ export declare class ConfigManager {
|
|
|
13
14
|
* Hydrates the config with user defined options and the
|
|
14
15
|
* command-line flags.
|
|
15
16
|
*/
|
|
16
|
-
hydrate():
|
|
17
|
+
hydrate(): NormalizedConfig;
|
|
17
18
|
}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import debug from './debug.js';
|
|
10
|
-
import { spec } from './reporters/main.js';
|
|
10
|
+
import { dot, ndjson, spec } from './reporters/main.js';
|
|
11
11
|
import { Refiner } from '../modules/core/main.js';
|
|
12
|
+
export const NOOP = () => { };
|
|
12
13
|
/**
|
|
13
14
|
* Defaults to use for configuration
|
|
14
15
|
*/
|
|
@@ -20,7 +21,7 @@ const DEFAULTS = {
|
|
|
20
21
|
plugins: [],
|
|
21
22
|
reporters: {
|
|
22
23
|
activated: ['spec'],
|
|
23
|
-
list: [spec()],
|
|
24
|
+
list: [spec(), ndjson(), dot()],
|
|
24
25
|
},
|
|
25
26
|
importer: (filePath) => import(filePath.href),
|
|
26
27
|
configureSuite: () => { },
|
|
@@ -128,7 +129,12 @@ export class ConfigManager {
|
|
|
128
129
|
timeout: cliTimeout ?? this.#config.timeout ?? DEFAULTS.timeout,
|
|
129
130
|
plugins: this.#config.plugins ?? DEFAULTS.plugins,
|
|
130
131
|
forceExit: cliForceExit ?? this.#config.forceExit ?? DEFAULTS.forceExit,
|
|
131
|
-
reporters: this.#config.reporters
|
|
132
|
+
reporters: this.#config.reporters
|
|
133
|
+
? {
|
|
134
|
+
activated: this.#config.reporters.activated,
|
|
135
|
+
list: this.#config.reporters.list || DEFAULTS.reporters.list,
|
|
136
|
+
}
|
|
137
|
+
: DEFAULTS.reporters,
|
|
132
138
|
configureSuite: this.#config.configureSuite ?? DEFAULTS.configureSuite,
|
|
133
139
|
setup: this.#config.setup || [],
|
|
134
140
|
teardown: this.#config.teardown || [],
|
|
@@ -153,7 +159,7 @@ export class ConfigManager {
|
|
|
153
159
|
files: suite.files,
|
|
154
160
|
timeout: cliTimeout ?? suite.timeout ?? baseConfig.timeout,
|
|
155
161
|
retries: cliRetries ?? suite.retries ?? baseConfig.retries,
|
|
156
|
-
configure: suite.configure,
|
|
162
|
+
configure: suite.configure || NOOP,
|
|
157
163
|
};
|
|
158
164
|
}),
|
|
159
165
|
...baseConfig,
|
package/build/src/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Runner } from '../modules/core/main.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NormalizedConfig } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Exposes API for working with global hooks
|
|
5
5
|
*/
|
|
@@ -8,7 +8,7 @@ export declare class GlobalHooks {
|
|
|
8
8
|
/**
|
|
9
9
|
* Apply hooks from the config
|
|
10
10
|
*/
|
|
11
|
-
apply(config:
|
|
11
|
+
apply(config: NormalizedConfig): void;
|
|
12
12
|
/**
|
|
13
13
|
* Perform setup
|
|
14
14
|
*/
|
package/build/src/planner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="@types/node" resolution-mode="require"/>
|
|
2
|
-
import type {
|
|
2
|
+
import type { NormalizedConfig, TestSuite } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* The tests planner is used to plan the tests by doing all
|
|
5
5
|
* the heavy lifting of executing plugins, registering
|
|
@@ -7,7 +7,7 @@ import type { Config, TestSuite } from './types.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class Planner {
|
|
9
9
|
#private;
|
|
10
|
-
constructor(config:
|
|
10
|
+
constructor(config: NormalizedConfig);
|
|
11
11
|
/**
|
|
12
12
|
* Creates a plan for running the tests
|
|
13
13
|
*/
|
|
@@ -20,6 +20,6 @@ export declare class Planner {
|
|
|
20
20
|
layer: "tags" | "tests" | "groups";
|
|
21
21
|
filters: string[];
|
|
22
22
|
}[];
|
|
23
|
-
config:
|
|
23
|
+
config: NormalizedConfig;
|
|
24
24
|
}>;
|
|
25
25
|
}
|
|
@@ -15,6 +15,6 @@ export declare function cacheFailedTests(tests: string[]): Promise<void>;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function clearCache(): Promise<void>;
|
|
17
17
|
/**
|
|
18
|
-
* Exposes the API to run failing tests using the "
|
|
18
|
+
* Exposes the API to run failing tests using the "failed" CLI flag.
|
|
19
19
|
*/
|
|
20
20
|
export declare const retryPlugin: PluginFn;
|
|
@@ -45,7 +45,7 @@ export async function clearCache() {
|
|
|
45
45
|
await unlink(SUMMARY_FILE);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Exposes the API to run failing tests using the "
|
|
48
|
+
* Exposes the API to run failing tests using the "failed" CLI flag.
|
|
49
49
|
*/
|
|
50
50
|
export const retryPlugin = async function retry({ config, cliArgs }) {
|
|
51
51
|
if (!SUMMARY_FILE) {
|
|
@@ -55,7 +55,7 @@ export const retryPlugin = async function retry({ config, cliArgs }) {
|
|
|
55
55
|
const summary = runner.getSummary();
|
|
56
56
|
await cacheFailedTests(summary.failedTestsTitles);
|
|
57
57
|
});
|
|
58
|
-
if (cliArgs.
|
|
58
|
+
if (cliArgs.failed) {
|
|
59
59
|
const { tests } = await getFailedTests();
|
|
60
60
|
if (!tests || !tests.length) {
|
|
61
61
|
console.log(cliui.colors.bgYellow().black(' No failing tests found. Running all the tests '));
|
package/build/src/types.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type CLIArgs = {
|
|
|
33
33
|
retries?: string;
|
|
34
34
|
reporter?: string | string[];
|
|
35
35
|
forceExit?: boolean;
|
|
36
|
+
failed?: boolean;
|
|
36
37
|
help?: boolean;
|
|
37
38
|
matchAll?: boolean;
|
|
38
39
|
} & Record<string, string | string[] | boolean>;
|
|
@@ -48,7 +49,7 @@ export type Filters = FilteringOptions & {
|
|
|
48
49
|
* emitter, config and the hooks
|
|
49
50
|
*/
|
|
50
51
|
export type PluginFn = (japa: {
|
|
51
|
-
config:
|
|
52
|
+
config: NormalizedConfig;
|
|
52
53
|
cliArgs: CLIArgs;
|
|
53
54
|
runner: Runner;
|
|
54
55
|
emitter: Emitter;
|
|
@@ -86,7 +87,7 @@ export type BaseConfig = {
|
|
|
86
87
|
*/
|
|
87
88
|
reporters?: {
|
|
88
89
|
activated: string[];
|
|
89
|
-
list
|
|
90
|
+
list?: NamedReporterContract[];
|
|
90
91
|
};
|
|
91
92
|
/**
|
|
92
93
|
* A collection of registered plugins
|
|
@@ -147,6 +148,15 @@ export type TestSuite = {
|
|
|
147
148
|
*/
|
|
148
149
|
retries?: number;
|
|
149
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* BaseConfig after normalized by the config manager
|
|
153
|
+
*/
|
|
154
|
+
export type NormalizedBaseConfig = Required<Omit<BaseConfig, 'reporters'>> & {
|
|
155
|
+
reporters: {
|
|
156
|
+
activated: string[];
|
|
157
|
+
list: NamedReporterContract[];
|
|
158
|
+
};
|
|
159
|
+
};
|
|
150
160
|
/**
|
|
151
161
|
* Configuration options
|
|
152
162
|
*/
|
|
@@ -155,3 +165,11 @@ export type Config = BaseConfig & ({
|
|
|
155
165
|
} | {
|
|
156
166
|
suites: TestSuite[];
|
|
157
167
|
});
|
|
168
|
+
/**
|
|
169
|
+
* Config after normalized by the config manager
|
|
170
|
+
*/
|
|
171
|
+
export type NormalizedConfig = NormalizedBaseConfig & ({
|
|
172
|
+
files: TestFiles;
|
|
173
|
+
} | {
|
|
174
|
+
suites: Required<TestSuite>[];
|
|
175
|
+
});
|
package/build/src/validator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NormalizedConfig } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validator encapsulates the validations to perform before running
|
|
4
4
|
* the tests
|
|
@@ -7,7 +7,7 @@ declare class Validator {
|
|
|
7
7
|
/**
|
|
8
8
|
* Ensures the japa is configured. Otherwise raises an exception
|
|
9
9
|
*/
|
|
10
|
-
ensureIsConfigured(config:
|
|
10
|
+
ensureIsConfigured(config: NormalizedConfig | undefined): void;
|
|
11
11
|
/**
|
|
12
12
|
* Ensures the japa is in planning phase
|
|
13
13
|
*/
|
|
@@ -15,16 +15,16 @@ declare class Validator {
|
|
|
15
15
|
/**
|
|
16
16
|
* Ensures the suites filter uses a subset of the user configured suites.
|
|
17
17
|
*/
|
|
18
|
-
validateSuitesFilter(config:
|
|
18
|
+
validateSuitesFilter(config: NormalizedConfig): void;
|
|
19
19
|
/**
|
|
20
20
|
* Ensure there are unique suites
|
|
21
21
|
*/
|
|
22
|
-
validateSuitesForUniqueness(config:
|
|
22
|
+
validateSuitesForUniqueness(config: NormalizedConfig): void;
|
|
23
23
|
/**
|
|
24
24
|
* Ensure the activated reporters are in the list of defined
|
|
25
25
|
* reporters
|
|
26
26
|
*/
|
|
27
|
-
validateActivatedReporters(config:
|
|
27
|
+
validateActivatedReporters(config: NormalizedConfig): void;
|
|
28
28
|
}
|
|
29
29
|
declare const _default: Validator;
|
|
30
30
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@japa/runner",
|
|
3
|
-
"version": "3.0.0-3",
|
|
4
3
|
"description": "Runner for Japa testing framework",
|
|
4
|
+
"version": "3.0.0-5",
|
|
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,13 +36,6 @@
|
|
|
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
40
|
"@adonisjs/eslint-config": "^1.1.7",
|
|
48
41
|
"@adonisjs/prettier-config": "^1.1.7",
|
|
@@ -50,12 +43,12 @@
|
|
|
50
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.
|
|
51
|
+
"@types/node": "^20.4.1",
|
|
59
52
|
"c8": "^8.0.0",
|
|
60
53
|
"chai": "^4.3.7",
|
|
61
54
|
"chai-subset": "^1.6.0",
|
|
@@ -63,7 +56,7 @@
|
|
|
63
56
|
"del-cli": "^5.0.0",
|
|
64
57
|
"eslint": "^8.44.0",
|
|
65
58
|
"github-label-sync": "^2.3.1",
|
|
66
|
-
"glob": "^10.3.
|
|
59
|
+
"glob": "^10.3.2",
|
|
67
60
|
"husky": "^8.0.3",
|
|
68
61
|
"japa": "^4.0.0",
|
|
69
62
|
"np": "^8.0.4",
|
|
@@ -72,7 +65,7 @@
|
|
|
72
65
|
"typescript": "^5.1.6"
|
|
73
66
|
},
|
|
74
67
|
"dependencies": {
|
|
75
|
-
"@japa/core": "^8.0.0-
|
|
68
|
+
"@japa/core": "^8.0.0-9",
|
|
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",
|
|
@@ -82,9 +75,9 @@
|
|
|
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",
|