@rstest/core 0.2.2 → 0.3.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/dist/{698.js → 12.js} +87 -33
- package/dist/223.js +135 -0
- package/dist/33.js +99 -58
- package/dist/85.js +84 -12
- package/dist/967.js +12 -8
- package/dist/971.js +57 -25
- package/dist/985.js +141 -70
- package/dist/index.js +33 -61
- package/dist/worker.js +9 -4
- package/dist-types/index.d.ts +54 -3
- package/dist-types/worker.d.ts +123 -4
- package/globals.d.ts +2 -0
- package/package.json +4 -4
package/dist/{698.js → 12.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
export const __webpack_id__ = "
|
|
3
|
+
export const __webpack_id__ = "12";
|
|
4
4
|
export const __webpack_ids__ = [
|
|
5
|
-
"
|
|
5
|
+
"12"
|
|
6
6
|
];
|
|
7
7
|
export const __webpack_modules__ = {
|
|
8
8
|
"../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -367,10 +367,10 @@ export const __webpack_modules__ = {
|
|
|
367
367
|
utils.vF.log(`${utils.yW.gray('Duration'.padStart(11))} ${(0, utils.kV)(duration.totalTime)} ${utils.yW.gray(`(build ${(0, utils.kV)(duration.buildTime)}, tests ${(0, utils.kV)(duration.testTime)})`)}`);
|
|
368
368
|
utils.vF.log('');
|
|
369
369
|
};
|
|
370
|
-
const printSummaryErrorLogs = async ({ testResults, results, rootPath, getSourcemap })=>{
|
|
370
|
+
const printSummaryErrorLogs = async ({ testResults, results, rootPath, getSourcemap, filterRerunTestPaths })=>{
|
|
371
371
|
const failedTests = [
|
|
372
|
-
...results.filter((i)=>'fail' === i.status && i.errors?.length),
|
|
373
|
-
...testResults.filter((i)=>'fail' === i.status)
|
|
372
|
+
...results.filter((i)=>'fail' === i.status && i.errors?.length && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true)),
|
|
373
|
+
...testResults.filter((i)=>'fail' === i.status && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true))
|
|
374
374
|
];
|
|
375
375
|
if (0 === failedTests.length) return;
|
|
376
376
|
utils.vF.log('');
|
|
@@ -468,14 +468,15 @@ export const __webpack_modules__ = {
|
|
|
468
468
|
async onExit() {
|
|
469
469
|
this.statusRenderer?.clear();
|
|
470
470
|
}
|
|
471
|
-
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary }) {
|
|
471
|
+
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths }) {
|
|
472
472
|
this.statusRenderer?.clear();
|
|
473
473
|
if (false === this.options.summary) return;
|
|
474
474
|
await printSummaryErrorLogs({
|
|
475
475
|
testResults,
|
|
476
476
|
results,
|
|
477
477
|
rootPath: this.rootPath,
|
|
478
|
-
getSourcemap
|
|
478
|
+
getSourcemap,
|
|
479
|
+
filterRerunTestPaths
|
|
479
480
|
});
|
|
480
481
|
printSummaryLog({
|
|
481
482
|
results,
|
|
@@ -551,6 +552,81 @@ export const __webpack_modules__ = {
|
|
|
551
552
|
}
|
|
552
553
|
}
|
|
553
554
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
555
|
+
function formatEnvironmentName(name) {
|
|
556
|
+
return name.replace(/[^a-zA-Z0-9\-_$]/g, '_');
|
|
557
|
+
}
|
|
558
|
+
class Rstest {
|
|
559
|
+
cwd;
|
|
560
|
+
command;
|
|
561
|
+
fileFilters;
|
|
562
|
+
configFilePath;
|
|
563
|
+
reporters;
|
|
564
|
+
snapshotManager;
|
|
565
|
+
version;
|
|
566
|
+
rootPath;
|
|
567
|
+
originalConfig;
|
|
568
|
+
normalizedConfig;
|
|
569
|
+
idMap = new Map();
|
|
570
|
+
reporterResults = {
|
|
571
|
+
results: [],
|
|
572
|
+
testResults: []
|
|
573
|
+
};
|
|
574
|
+
projects = [];
|
|
575
|
+
constructor({ cwd = process.cwd(), command, fileFilters, configFilePath, projects }, userConfig){
|
|
576
|
+
this.cwd = cwd;
|
|
577
|
+
this.command = command;
|
|
578
|
+
this.fileFilters = fileFilters;
|
|
579
|
+
this.configFilePath = configFilePath;
|
|
580
|
+
const rootPath = userConfig.root ? (0, helper.FI)(cwd, userConfig.root) : cwd;
|
|
581
|
+
const rstestConfig = (0, src_config.wX)(userConfig);
|
|
582
|
+
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
583
|
+
rootPath,
|
|
584
|
+
config: rstestConfig
|
|
585
|
+
}) : [];
|
|
586
|
+
const snapshotManager = new SnapshotManager({
|
|
587
|
+
updateSnapshot: rstestConfig.update ? 'all' : external_std_env_.isCI ? 'none' : 'new'
|
|
588
|
+
});
|
|
589
|
+
this.reporters = reporters;
|
|
590
|
+
this.snapshotManager = snapshotManager;
|
|
591
|
+
this.version = "0.3.0";
|
|
592
|
+
this.rootPath = rootPath;
|
|
593
|
+
this.originalConfig = userConfig;
|
|
594
|
+
this.normalizedConfig = rstestConfig;
|
|
595
|
+
this.projects = projects.length ? projects.map((project)=>{
|
|
596
|
+
const config = (0, src_config.wX)(project.config);
|
|
597
|
+
return {
|
|
598
|
+
configFilePath: project.configFilePath,
|
|
599
|
+
rootPath: config.root,
|
|
600
|
+
name: config.name,
|
|
601
|
+
environmentName: formatEnvironmentName(config.name),
|
|
602
|
+
normalizedConfig: config
|
|
603
|
+
};
|
|
604
|
+
}) : [
|
|
605
|
+
{
|
|
606
|
+
configFilePath,
|
|
607
|
+
rootPath,
|
|
608
|
+
name: rstestConfig.name,
|
|
609
|
+
environmentName: formatEnvironmentName(rstestConfig.name),
|
|
610
|
+
normalizedConfig: rstestConfig
|
|
611
|
+
}
|
|
612
|
+
];
|
|
613
|
+
}
|
|
614
|
+
updateReporterResultState(results, testResults, deletedEntries = []) {
|
|
615
|
+
results.forEach((item)=>{
|
|
616
|
+
const existingIndex = this.reporterResults.results.findIndex((r)=>r.testPath === item.testPath);
|
|
617
|
+
if (-1 !== existingIndex) this.reporterResults.results[existingIndex] = item;
|
|
618
|
+
else this.reporterResults.results.push(item);
|
|
619
|
+
});
|
|
620
|
+
const testPathsToUpdate = new Set(testResults.map((r)=>r.testPath));
|
|
621
|
+
this.reporterResults.testResults = this.reporterResults.testResults.filter((r)=>!testPathsToUpdate.has(r.testPath));
|
|
622
|
+
this.reporterResults.testResults.push(...testResults);
|
|
623
|
+
if (deletedEntries.length > 0) {
|
|
624
|
+
const deletedPathsSet = new Set(deletedEntries);
|
|
625
|
+
this.reporterResults.results = this.reporterResults.results.filter((r)=>!deletedPathsSet.has(r.testPath));
|
|
626
|
+
this.reporterResults.testResults = this.reporterResults.testResults.filter((r)=>!deletedPathsSet.has(r.testPath));
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
554
630
|
const reportersMap = {
|
|
555
631
|
default: DefaultReporter,
|
|
556
632
|
verbose: VerboseReporter,
|
|
@@ -576,35 +652,13 @@ export const __webpack_modules__ = {
|
|
|
576
652
|
});
|
|
577
653
|
return result;
|
|
578
654
|
}
|
|
579
|
-
function
|
|
580
|
-
const
|
|
581
|
-
const rootPath = userConfig.root ? (0, helper.FI)(cwd, userConfig.root) : cwd;
|
|
582
|
-
const rstestConfig = (0, src_config.wX)(userConfig);
|
|
583
|
-
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
584
|
-
rootPath,
|
|
585
|
-
config: rstestConfig
|
|
586
|
-
}) : [];
|
|
587
|
-
const snapshotManager = new SnapshotManager({
|
|
588
|
-
updateSnapshot: rstestConfig.update ? 'all' : external_std_env_.isCI ? 'none' : 'new'
|
|
589
|
-
});
|
|
590
|
-
return {
|
|
591
|
-
configFilePath,
|
|
592
|
-
command,
|
|
593
|
-
version: "0.2.2",
|
|
594
|
-
rootPath,
|
|
595
|
-
reporters,
|
|
596
|
-
fileFilters,
|
|
597
|
-
snapshotManager,
|
|
598
|
-
originalConfig: userConfig,
|
|
599
|
-
normalizedConfig: rstestConfig
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
function createRstest({ config, configFilePath }, command, fileFilters) {
|
|
603
|
-
const context = createContext({
|
|
655
|
+
function createRstest({ config, projects, configFilePath }, command, fileFilters) {
|
|
656
|
+
const context = new Rstest({
|
|
604
657
|
cwd: process.cwd(),
|
|
605
658
|
command,
|
|
606
659
|
fileFilters,
|
|
607
|
-
configFilePath
|
|
660
|
+
configFilePath,
|
|
661
|
+
projects
|
|
608
662
|
}, config);
|
|
609
663
|
const runTests = async ()=>{
|
|
610
664
|
const { runTests } = await Promise.all([
|
package/dist/223.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
export const __webpack_id__ = "223";
|
|
4
|
+
export const __webpack_ids__ = [
|
|
5
|
+
"223"
|
|
6
|
+
];
|
|
7
|
+
export const __webpack_modules__ = {
|
|
8
|
+
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
9
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
10
|
+
initCli: ()=>initCli
|
|
11
|
+
});
|
|
12
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
13
|
+
var pathe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("pathe");
|
|
14
|
+
var tinyglobby__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs");
|
|
15
|
+
var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/config.ts");
|
|
16
|
+
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
17
|
+
async function resolveConfig(options) {
|
|
18
|
+
const { content: config, filePath: configFilePath } = await (0, _config__WEBPACK_IMPORTED_MODULE_2__.Z9)({
|
|
19
|
+
cwd: options.root,
|
|
20
|
+
path: options.config,
|
|
21
|
+
configLoader: options.configLoader
|
|
22
|
+
});
|
|
23
|
+
const keys = [
|
|
24
|
+
'root',
|
|
25
|
+
'globals',
|
|
26
|
+
'isolate',
|
|
27
|
+
'passWithNoTests',
|
|
28
|
+
'update',
|
|
29
|
+
'testNamePattern',
|
|
30
|
+
'testTimeout',
|
|
31
|
+
'hookTimeout',
|
|
32
|
+
'clearMocks',
|
|
33
|
+
'resetMocks',
|
|
34
|
+
'restoreMocks',
|
|
35
|
+
'unstubEnvs',
|
|
36
|
+
'unstubGlobals',
|
|
37
|
+
'retry',
|
|
38
|
+
'slowTestThreshold',
|
|
39
|
+
'maxConcurrency',
|
|
40
|
+
'printConsoleTrace',
|
|
41
|
+
'disableConsoleIntercept',
|
|
42
|
+
'testEnvironment'
|
|
43
|
+
];
|
|
44
|
+
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
45
|
+
if (options.reporter) config.reporters = (0, _utils__WEBPACK_IMPORTED_MODULE_3__.bg)(options.reporter);
|
|
46
|
+
if (options.exclude) config.exclude = (0, _utils__WEBPACK_IMPORTED_MODULE_3__.bg)(options.exclude);
|
|
47
|
+
if (options.include) config.include = (0, _utils__WEBPACK_IMPORTED_MODULE_3__.bg)(options.include);
|
|
48
|
+
return {
|
|
49
|
+
config,
|
|
50
|
+
configFilePath: configFilePath ?? void 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function resolveProjects({ config, root, options }) {
|
|
54
|
+
if (!config.projects || !config.projects.length) return [];
|
|
55
|
+
const getDefaultProjectName = (dir)=>{
|
|
56
|
+
const pkgJsonPath = (0, pathe__WEBPACK_IMPORTED_MODULE_1__.resolve)(dir, 'package.json');
|
|
57
|
+
const name = (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(pkgJsonPath) ? JSON.parse((0, node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync)(pkgJsonPath, 'utf-8')).name : '';
|
|
58
|
+
if ('string' != typeof name || !name) return (0, pathe__WEBPACK_IMPORTED_MODULE_1__.basename)(dir);
|
|
59
|
+
return name;
|
|
60
|
+
};
|
|
61
|
+
const globProjects = async (patterns)=>{
|
|
62
|
+
const globOptions = {
|
|
63
|
+
absolute: true,
|
|
64
|
+
dot: true,
|
|
65
|
+
onlyFiles: false,
|
|
66
|
+
cwd: root,
|
|
67
|
+
expandDirectories: false,
|
|
68
|
+
ignore: [
|
|
69
|
+
'**/node_modules/**',
|
|
70
|
+
'**/.DS_Store'
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
return (0, tinyglobby__WEBPACK_IMPORTED_MODULE_4__.glob)(patterns, globOptions);
|
|
74
|
+
};
|
|
75
|
+
const { projectPaths, projectPatterns } = (config.projects || []).reduce((total, p)=>{
|
|
76
|
+
const projectStr = p.replace('<rootDir>', root);
|
|
77
|
+
if ((0, tinyglobby__WEBPACK_IMPORTED_MODULE_4__.ey)(projectStr)) total.projectPatterns.push(projectStr);
|
|
78
|
+
else {
|
|
79
|
+
const absolutePath = (0, _utils__WEBPACK_IMPORTED_MODULE_3__.FI)(root, projectStr);
|
|
80
|
+
if (!(0, node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
|
|
81
|
+
total.projectPaths.push(absolutePath);
|
|
82
|
+
}
|
|
83
|
+
return total;
|
|
84
|
+
}, {
|
|
85
|
+
projectPaths: [],
|
|
86
|
+
projectPatterns: []
|
|
87
|
+
});
|
|
88
|
+
projectPaths.push(...await globProjects(projectPatterns));
|
|
89
|
+
const projects = await Promise.all(projectPaths.map(async (project)=>{
|
|
90
|
+
const isDirectory = (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.statSync)(project).isDirectory();
|
|
91
|
+
const { config, configFilePath } = await resolveConfig({
|
|
92
|
+
...options,
|
|
93
|
+
config: isDirectory ? void 0 : project,
|
|
94
|
+
root: isDirectory ? project : (0, pathe__WEBPACK_IMPORTED_MODULE_1__.dirname)(project)
|
|
95
|
+
});
|
|
96
|
+
config.name ??= getDefaultProjectName(project);
|
|
97
|
+
if (config.projects?.length && config.root !== root) _utils__WEBPACK_IMPORTED_MODULE_3__.vF.warn(`Projects cannot have nested projects, the "projects" field in project "${config.name}" will be ignored.`);
|
|
98
|
+
return {
|
|
99
|
+
config,
|
|
100
|
+
configFilePath
|
|
101
|
+
};
|
|
102
|
+
}));
|
|
103
|
+
const names = new Set();
|
|
104
|
+
projects.forEach((project)=>{
|
|
105
|
+
if (names.has(project.config.name)) {
|
|
106
|
+
const conflictProjects = projects.filter((p)=>p.config.name === project.config.name);
|
|
107
|
+
throw `Project name "${project.config.name}" is already used. Please ensure all projects have unique names.
|
|
108
|
+
Conflicting projects:
|
|
109
|
+
${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')}
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
names.add(project.config.name);
|
|
113
|
+
});
|
|
114
|
+
return projects;
|
|
115
|
+
}
|
|
116
|
+
async function initCli(options) {
|
|
117
|
+
const cwd = process.cwd();
|
|
118
|
+
const root = options.root ? (0, _utils__WEBPACK_IMPORTED_MODULE_3__.FI)(cwd, options.root) : cwd;
|
|
119
|
+
const { config, configFilePath } = await resolveConfig({
|
|
120
|
+
...options,
|
|
121
|
+
root
|
|
122
|
+
});
|
|
123
|
+
const projects = await resolveProjects({
|
|
124
|
+
config,
|
|
125
|
+
root,
|
|
126
|
+
options
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
config,
|
|
130
|
+
configFilePath,
|
|
131
|
+
projects
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
package/dist/33.js
CHANGED
|
@@ -110,9 +110,9 @@ export const __webpack_modules__ = {
|
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
key: 'c',
|
|
113
|
-
description: `${utils.yW.bold('c')} ${utils.yW.dim('clear
|
|
113
|
+
description: `${utils.yW.bold('c')} ${utils.yW.dim('clear screen')}`,
|
|
114
114
|
action: ()=>{
|
|
115
|
-
|
|
115
|
+
(0, utils.mT)(true);
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
{
|
|
@@ -154,9 +154,10 @@ export const __webpack_modules__ = {
|
|
|
154
154
|
}
|
|
155
155
|
var rsbuild = __webpack_require__("./src/core/rsbuild.ts");
|
|
156
156
|
async function runTests(context) {
|
|
157
|
-
const {
|
|
157
|
+
const { rootPath, reporters, projects, snapshotManager, command } = context;
|
|
158
158
|
const entriesCache = new Map();
|
|
159
|
-
const globTestSourceEntries = async ()=>{
|
|
159
|
+
const globTestSourceEntries = async (name)=>{
|
|
160
|
+
const { include, exclude, includeSource, root } = projects.find((p)=>p.environmentName === name).normalizedConfig;
|
|
160
161
|
const entries = await (0, utils.tG)({
|
|
161
162
|
include,
|
|
162
163
|
exclude,
|
|
@@ -168,24 +169,21 @@ export const __webpack_modules__ = {
|
|
|
168
169
|
entries,
|
|
169
170
|
fileFilters: context.fileFilters
|
|
170
171
|
});
|
|
171
|
-
if (!Object.keys(entries).length) {
|
|
172
|
-
utils.vF.log(utils.yW.red('No test files found.'));
|
|
173
|
-
utils.vF.log('');
|
|
174
|
-
if (context.fileFilters?.length) utils.vF.log(utils.yW.gray('filter: '), context.fileFilters.join(utils.yW.gray(', ')));
|
|
175
|
-
utils.vF.log(utils.yW.gray('include:'), include.join(utils.yW.gray(', ')));
|
|
176
|
-
utils.vF.log(utils.yW.gray('exclude:'), exclude.join(utils.yW.gray(', ')));
|
|
177
|
-
utils.vF.log('');
|
|
178
|
-
}
|
|
179
172
|
return entries;
|
|
180
173
|
};
|
|
181
|
-
const setupFiles = (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
174
|
+
const setupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
175
|
+
const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
|
|
176
|
+
return [
|
|
177
|
+
environmentName,
|
|
178
|
+
(0, utils.pr)(setupFiles, rootPath)
|
|
179
|
+
];
|
|
180
|
+
}));
|
|
181
|
+
const rsbuildInstance = await (0, rsbuild.zh)(context, globTestSourceEntries, setupFiles);
|
|
182
|
+
const { getRsbuildStats, closeServer } = await (0, rsbuild.XD)({
|
|
185
183
|
normalizedConfig: context.normalizedConfig,
|
|
186
|
-
globTestSourceEntries: 'watch' === command ? globTestSourceEntries : async ()=>{
|
|
184
|
+
globTestSourceEntries: 'watch' === command ? globTestSourceEntries : async (name)=>{
|
|
187
185
|
if (entriesCache.has(name)) return entriesCache.get(name).entries;
|
|
188
|
-
return globTestSourceEntries();
|
|
186
|
+
return globTestSourceEntries(name);
|
|
189
187
|
},
|
|
190
188
|
setupFiles,
|
|
191
189
|
rsbuildInstance,
|
|
@@ -196,37 +194,78 @@ export const __webpack_modules__ = {
|
|
|
196
194
|
context,
|
|
197
195
|
recommendWorkerCount
|
|
198
196
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
197
|
+
const run = async ({ fileFilters, mode = 'all' } = {})=>{
|
|
198
|
+
let testStart;
|
|
199
|
+
const buildStart = Date.now();
|
|
200
|
+
const currentEntries = [];
|
|
201
|
+
const currentDeletedEntries = [];
|
|
202
|
+
const returns = await Promise.all(context.projects.map(async (p)=>{
|
|
203
|
+
const { entries, setupEntries, assetFiles, sourceMaps, affectedEntries, deletedEntries } = await getRsbuildStats({
|
|
204
|
+
environmentName: p.environmentName,
|
|
205
|
+
fileFilters
|
|
206
|
+
});
|
|
207
|
+
testStart ??= Date.now();
|
|
208
|
+
currentDeletedEntries.push(...deletedEntries);
|
|
209
|
+
let finalEntries = entries;
|
|
210
|
+
if ('on-demand' === mode) {
|
|
211
|
+
if (0 === affectedEntries.length) utils.vF.debug(utils.yW.yellow(`No test files need re-run in project(${p.environmentName}).`));
|
|
212
|
+
else utils.vF.debug(utils.yW.yellow(`Test files to re-run in project(${p.environmentName}):\n`) + affectedEntries.map((e)=>e.testPath).join('\n') + '\n');
|
|
213
|
+
finalEntries = affectedEntries;
|
|
214
|
+
} else utils.vF.debug(utils.yW.yellow(fileFilters?.length ? `Run filtered tests in project(${p.environmentName}).\n` : `Run all tests in project(${p.environmentName}).\n`));
|
|
215
|
+
currentEntries.push(...finalEntries);
|
|
216
|
+
const { results, testResults } = await pool.runTests({
|
|
217
|
+
entries: finalEntries,
|
|
218
|
+
sourceMaps,
|
|
219
|
+
setupEntries,
|
|
220
|
+
assetFiles,
|
|
221
|
+
project: p,
|
|
222
|
+
updateSnapshot: context.snapshotManager.options.updateSnapshot
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
results,
|
|
226
|
+
testResults,
|
|
227
|
+
sourceMaps
|
|
228
|
+
};
|
|
229
|
+
}));
|
|
230
|
+
const buildTime = testStart - buildStart;
|
|
215
231
|
const testTime = Date.now() - testStart;
|
|
216
232
|
const duration = {
|
|
217
|
-
totalTime: testTime +
|
|
218
|
-
buildTime
|
|
233
|
+
totalTime: testTime + buildTime,
|
|
234
|
+
buildTime,
|
|
219
235
|
testTime
|
|
220
236
|
};
|
|
221
|
-
|
|
222
|
-
|
|
237
|
+
const results = returns.flatMap((r)=>r.results);
|
|
238
|
+
const testResults = returns.flatMap((r)=>r.testResults);
|
|
239
|
+
const sourceMaps = Object.assign({}, ...returns.map((r)=>r.sourceMaps));
|
|
240
|
+
context.updateReporterResultState(results, testResults, currentDeletedEntries);
|
|
241
|
+
if (0 === results.length) {
|
|
242
|
+
if ('watch' === command) if ('on-demand' === mode) utils.vF.log(utils.yW.yellow('No test files need re-run.'));
|
|
243
|
+
else utils.vF.log(utils.yW.yellow('No test files found.'));
|
|
244
|
+
else {
|
|
245
|
+
const code = context.normalizedConfig.passWithNoTests ? 0 : 1;
|
|
246
|
+
utils.vF.log(utils.yW[code ? 'red' : 'yellow'](`No test files found, exiting with code ${code}.`));
|
|
247
|
+
process.exitCode = code;
|
|
248
|
+
}
|
|
249
|
+
if ('all' === mode) {
|
|
250
|
+
if (context.fileFilters?.length) utils.vF.log(utils.yW.gray('filter: '), context.fileFilters.join(utils.yW.gray(', ')));
|
|
251
|
+
context.projects.forEach((p)=>{
|
|
252
|
+
if (context.projects.length > 1) {
|
|
253
|
+
utils.vF.log('');
|
|
254
|
+
utils.vF.log(utils.yW.gray('project:'), p.name);
|
|
255
|
+
}
|
|
256
|
+
utils.vF.log(utils.yW.gray('include:'), p.normalizedConfig.include.join(utils.yW.gray(', ')));
|
|
257
|
+
utils.vF.log(utils.yW.gray('exclude:'), p.normalizedConfig.exclude.join(utils.yW.gray(', ')));
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
223
261
|
if (results.some((r)=>'fail' === r.status)) process.exitCode = 1;
|
|
224
262
|
for (const reporter of reporters)await reporter.onTestRunEnd?.({
|
|
225
|
-
results,
|
|
226
|
-
testResults,
|
|
263
|
+
results: context.reporterResults.results,
|
|
264
|
+
testResults: context.reporterResults.testResults,
|
|
227
265
|
snapshotSummary: snapshotManager.summary,
|
|
228
266
|
duration,
|
|
229
|
-
getSourcemap
|
|
267
|
+
getSourcemap: (name)=>sourceMaps[name] || null,
|
|
268
|
+
filterRerunTestPaths: currentEntries.length ? currentEntries.map((e)=>e.testPath) : void 0
|
|
230
269
|
});
|
|
231
270
|
};
|
|
232
271
|
if ('watch' === command) {
|
|
@@ -236,20 +275,19 @@ export const __webpack_modules__ = {
|
|
|
236
275
|
if (enableCliShortcuts) if (snapshotManager.summary.unmatched) utils.vF.log(` ${utils.yW.dim('press')} ${utils.yW.yellow(utils.yW.bold('u'))} ${utils.yW.dim('to update snapshot')}${utils.yW.dim(', press')} ${utils.yW.bold('h')} ${utils.yW.dim('to show help')}\n`);
|
|
237
276
|
else utils.vF.log(` ${utils.yW.dim('press')} ${utils.yW.bold('h')} ${utils.yW.dim('to show help')}${utils.yW.dim(', press')} ${utils.yW.bold('q')} ${utils.yW.dim('to quit')}\n`);
|
|
238
277
|
};
|
|
239
|
-
const clearLogs = ()=>{
|
|
240
|
-
console.clear();
|
|
241
|
-
};
|
|
242
278
|
const { onBeforeRestart } = await __webpack_require__.e("967").then(__webpack_require__.bind(__webpack_require__, "./src/core/restart.ts"));
|
|
243
279
|
onBeforeRestart(async ()=>{
|
|
244
280
|
await pool.close();
|
|
245
281
|
await closeServer();
|
|
246
282
|
});
|
|
247
283
|
rsbuildInstance.onBeforeDevCompile(({ isFirstCompile })=>{
|
|
248
|
-
if (!isFirstCompile)
|
|
284
|
+
if (!isFirstCompile) (0, utils.mT)();
|
|
249
285
|
});
|
|
250
286
|
rsbuildInstance.onAfterDevCompile(async ({ isFirstCompile })=>{
|
|
251
287
|
snapshotManager.clear();
|
|
252
|
-
await run(
|
|
288
|
+
await run({
|
|
289
|
+
mode: isFirstCompile ? 'all' : 'on-demand'
|
|
290
|
+
});
|
|
253
291
|
if (isFirstCompile && enableCliShortcuts) {
|
|
254
292
|
const closeCliShortcuts = await setupCliShortcuts({
|
|
255
293
|
closeServer: async ()=>{
|
|
@@ -257,15 +295,17 @@ export const __webpack_modules__ = {
|
|
|
257
295
|
await closeServer();
|
|
258
296
|
},
|
|
259
297
|
runAll: async ()=>{
|
|
260
|
-
|
|
298
|
+
(0, utils.mT)();
|
|
261
299
|
snapshotManager.clear();
|
|
262
300
|
context.normalizedConfig.testNamePattern = void 0;
|
|
263
301
|
context.fileFilters = void 0;
|
|
264
|
-
await run(
|
|
302
|
+
await run({
|
|
303
|
+
mode: 'all'
|
|
304
|
+
});
|
|
265
305
|
afterTestsWatchRun();
|
|
266
306
|
},
|
|
267
307
|
runWithTestNamePattern: async (pattern)=>{
|
|
268
|
-
|
|
308
|
+
(0, utils.mT)();
|
|
269
309
|
context.normalizedConfig.testNamePattern = pattern;
|
|
270
310
|
if (pattern) utils.vF.log(`\n${utils.yW.dim('Applied testNamePattern:')} ${utils.yW.bold(pattern)}\n`);
|
|
271
311
|
else utils.vF.log(`\n${utils.yW.dim('Cleared testNamePattern filter')}\n`);
|
|
@@ -274,32 +314,33 @@ export const __webpack_modules__ = {
|
|
|
274
314
|
afterTestsWatchRun();
|
|
275
315
|
},
|
|
276
316
|
runWithFileFilters: async (filters)=>{
|
|
277
|
-
|
|
317
|
+
(0, utils.mT)();
|
|
278
318
|
if (filters && filters.length > 0) utils.vF.log(`\n${utils.yW.dim('Applied file filters:')} ${utils.yW.bold(filters.join(', '))}\n`);
|
|
279
319
|
else utils.vF.log(`\n${utils.yW.dim('Cleared file filters')}\n`);
|
|
280
320
|
snapshotManager.clear();
|
|
281
321
|
context.fileFilters = filters;
|
|
282
|
-
const entries = await globTestSourceEntries();
|
|
283
|
-
if (!
|
|
322
|
+
const entries = await Promise.all(projects.map(async (p)=>globTestSourceEntries(p.environmentName))).then((entries)=>entries.reduce((acc, entry)=>acc.concat(...Object.values(entry)), []));
|
|
323
|
+
if (!entries.length) return void utils.vF.log(filters ? utils.yW.yellow(`\nNo matching test files to run with current file filters: ${filters.join(',')}\n`) : utils.yW.yellow('\nNo matching test files to run.\n'));
|
|
284
324
|
await run({
|
|
285
|
-
fileFilters:
|
|
325
|
+
fileFilters: entries
|
|
286
326
|
});
|
|
287
327
|
afterTestsWatchRun();
|
|
288
328
|
},
|
|
289
329
|
runFailedTests: async ()=>{
|
|
290
|
-
const failedTests =
|
|
330
|
+
const failedTests = context.reporterResults.results.filter((result)=>'fail' === result.status).map((r)=>r.testPath);
|
|
291
331
|
if (!failedTests.length) return void utils.vF.log(utils.yW.yellow('\nNo failed tests were found that needed to be rerun.'));
|
|
292
|
-
|
|
332
|
+
(0, utils.mT)();
|
|
293
333
|
snapshotManager.clear();
|
|
294
334
|
await run({
|
|
295
|
-
fileFilters: failedTests
|
|
335
|
+
fileFilters: failedTests,
|
|
336
|
+
mode: 'all'
|
|
296
337
|
});
|
|
297
338
|
afterTestsWatchRun();
|
|
298
339
|
},
|
|
299
340
|
updateSnapshot: async ()=>{
|
|
300
341
|
if (!snapshotManager.summary.unmatched) return void utils.vF.log(utils.yW.yellow('\nNo snapshots were found that needed to be updated.'));
|
|
301
|
-
const failedTests =
|
|
302
|
-
|
|
342
|
+
const failedTests = context.reporterResults.results.filter((result)=>result.snapshotResult?.unmatched).map((r)=>r.testPath);
|
|
343
|
+
(0, utils.mT)();
|
|
303
344
|
const originalUpdateSnapshot = snapshotManager.options.updateSnapshot;
|
|
304
345
|
snapshotManager.clear();
|
|
305
346
|
snapshotManager.options.updateSnapshot = 'all';
|