@rstest/core 0.7.2 → 0.7.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/dist/0~130.js +2 -1
- package/dist/0~151.js +213 -77
- package/dist/0~173.js +69 -32
- package/dist/0~255.js +2 -2
- package/dist/0~403.js +8 -7
- package/dist/0~426.js +5 -3
- package/dist/0~583.js +3 -2
- package/dist/0~588.js +7 -5
- package/dist/0~62.js +1 -1
- package/dist/0~634.js +68 -22
- package/dist/0~809.js +1 -1
- package/dist/0~835.js +4 -3
- package/dist/{0~122.js → 0~89.js} +122 -20
- package/dist/0~919.js +6 -6
- package/dist/0~923.js +4 -3
- package/dist/131.js +87 -151
- package/dist/{946.js → 157.js} +15 -852
- package/dist/198.js +4 -0
- package/dist/{404.js → 216.js} +1 -2
- package/dist/278.js +765 -0
- package/dist/554.js +11 -6716
- package/dist/664.js +93 -0
- package/dist/672.js +91 -0
- package/dist/734.js +4 -3
- package/dist/913.js +6717 -0
- package/dist/globalSetupWorker.d.ts +9 -0
- package/dist/globalSetupWorker.js +115 -0
- package/dist/index.d.ts +266 -26
- package/dist/index.js +1 -1
- package/dist/mockRuntimeCode.js +1 -0
- package/dist/worker.d.ts +184 -28
- package/package.json +3 -2
- /package/dist/{554.js.LICENSE.txt → 913.js.LICENSE.txt} +0 -0
package/dist/0~173.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
4
|
+
import "./664.js";
|
|
5
|
+
import { getTestEntries, getSetupFiles, isTTY } from "./157.js";
|
|
5
6
|
import { createCoverageProvider } from "./734.js";
|
|
6
|
-
import { prepareRsbuild, createPool, createRsbuildServer } from "./0~
|
|
7
|
+
import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
|
|
8
|
+
import { clearScreen, logger_logger } from "./278.js";
|
|
7
9
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
8
10
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
9
11
|
const isCliShortcutsEnabled = ()=>isTTY('stdin');
|
|
@@ -134,7 +136,7 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
134
136
|
clearCurrentInputLine();
|
|
135
137
|
let message = ` ${picocolors_default().bold(picocolors_default().blue('Shortcuts:'))}\n`;
|
|
136
138
|
for (const shortcut of shortcuts)message += ` ${shortcut.description}\n`;
|
|
137
|
-
|
|
139
|
+
logger_logger.log(message);
|
|
138
140
|
}
|
|
139
141
|
};
|
|
140
142
|
process.stdin.on('keypress', handleKeypress);
|
|
@@ -173,7 +175,14 @@ async function runTests(context) {
|
|
|
173
175
|
getSetupFiles(setupFiles, rootPath)
|
|
174
176
|
];
|
|
175
177
|
}));
|
|
176
|
-
const
|
|
178
|
+
const globalSetupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
179
|
+
const { environmentName, rootPath, normalizedConfig: { globalSetup } } = project;
|
|
180
|
+
return [
|
|
181
|
+
environmentName,
|
|
182
|
+
getSetupFiles(globalSetup, rootPath)
|
|
183
|
+
];
|
|
184
|
+
}));
|
|
185
|
+
const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles);
|
|
177
186
|
const { getRsbuildStats, closeServer } = await createRsbuildServer({
|
|
178
187
|
inspectedConfig: {
|
|
179
188
|
...context.normalizedConfig,
|
|
@@ -184,6 +193,7 @@ async function runTests(context) {
|
|
|
184
193
|
return globTestSourceEntries(name);
|
|
185
194
|
},
|
|
186
195
|
setupFiles,
|
|
196
|
+
globalSetupFiles,
|
|
187
197
|
rsbuildInstance,
|
|
188
198
|
rootPath
|
|
189
199
|
});
|
|
@@ -193,25 +203,45 @@ async function runTests(context) {
|
|
|
193
203
|
recommendWorkerCount
|
|
194
204
|
});
|
|
195
205
|
const coverageProvider = coverage.enabled ? await createCoverageProvider(coverage, context.rootPath) : null;
|
|
196
|
-
if (coverageProvider)
|
|
206
|
+
if (coverageProvider) logger_logger.log(` ${picocolors_default().gray('Coverage enabled with')} %s\n`, picocolors_default().yellow(coverage.provider));
|
|
197
207
|
const run = async ({ fileFilters, mode = 'all', buildStart = Date.now() } = {})=>{
|
|
198
208
|
let testStart;
|
|
199
209
|
const currentEntries = [];
|
|
200
210
|
const currentDeletedEntries = [];
|
|
201
211
|
context.stateManager.reset();
|
|
202
212
|
const returns = await Promise.all(context.projects.map(async (p)=>{
|
|
203
|
-
const { assetNames, entries, setupEntries, getAssetFiles, getSourceMaps, affectedEntries, deletedEntries } = await getRsbuildStats({
|
|
213
|
+
const { assetNames, entries, setupEntries, globalSetupEntries, getAssetFiles, getSourceMaps, affectedEntries, deletedEntries } = await getRsbuildStats({
|
|
204
214
|
environmentName: p.environmentName,
|
|
205
215
|
fileFilters
|
|
206
216
|
});
|
|
207
217
|
testStart ??= Date.now();
|
|
218
|
+
if (entries.length && globalSetupEntries.length && !p._globalSetups) {
|
|
219
|
+
p._globalSetups = true;
|
|
220
|
+
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
221
|
+
const assetFiles = await getAssetFiles(files);
|
|
222
|
+
const sourceMaps = await getSourceMaps(files);
|
|
223
|
+
const { success, errors } = await runGlobalSetup({
|
|
224
|
+
globalSetupEntries,
|
|
225
|
+
assetFiles,
|
|
226
|
+
sourceMaps,
|
|
227
|
+
interopDefault: true,
|
|
228
|
+
outputModule: p.outputModule
|
|
229
|
+
});
|
|
230
|
+
if (!success) return {
|
|
231
|
+
results: [],
|
|
232
|
+
testResults: [],
|
|
233
|
+
errors,
|
|
234
|
+
assetNames,
|
|
235
|
+
getSourceMaps: ()=>null
|
|
236
|
+
};
|
|
237
|
+
}
|
|
208
238
|
currentDeletedEntries.push(...deletedEntries);
|
|
209
239
|
let finalEntries = entries;
|
|
210
240
|
if ('on-demand' === mode) {
|
|
211
|
-
if (0 === affectedEntries.length)
|
|
212
|
-
else
|
|
241
|
+
if (0 === affectedEntries.length) logger_logger.debug(picocolors_default().yellow(`No test files need re-run in project(${p.environmentName}).`));
|
|
242
|
+
else logger_logger.debug(picocolors_default().yellow(`Test files to re-run in project(${p.environmentName}):\n`) + affectedEntries.map((e)=>e.testPath).join('\n') + '\n');
|
|
213
243
|
finalEntries = affectedEntries;
|
|
214
|
-
} else
|
|
244
|
+
} else logger_logger.debug(picocolors_default().yellow(fileFilters?.length ? `Run filtered tests in project(${p.environmentName}).\n` : `Run all tests in project(${p.environmentName}).\n`));
|
|
215
245
|
currentEntries.push(...finalEntries);
|
|
216
246
|
const { results, testResults } = await pool.runTests({
|
|
217
247
|
entries: finalEntries,
|
|
@@ -237,32 +267,34 @@ async function runTests(context) {
|
|
|
237
267
|
};
|
|
238
268
|
const results = returns.flatMap((r)=>r.results);
|
|
239
269
|
const testResults = returns.flatMap((r)=>r.testResults);
|
|
270
|
+
const errors = returns.flatMap((r)=>r.errors || []);
|
|
240
271
|
context.updateReporterResultState(results, testResults, currentDeletedEntries);
|
|
241
|
-
if (0 === results.length) {
|
|
242
|
-
if ('watch' === command) if ('on-demand' === mode)
|
|
243
|
-
else
|
|
272
|
+
if (0 === results.length && !errors.length) {
|
|
273
|
+
if ('watch' === command) if ('on-demand' === mode) logger_logger.log(picocolors_default().yellow('No test files need re-run.'));
|
|
274
|
+
else logger_logger.log(picocolors_default().yellow('No test files found.'));
|
|
244
275
|
else {
|
|
245
276
|
const code = context.normalizedConfig.passWithNoTests ? 0 : 1;
|
|
246
|
-
|
|
277
|
+
logger_logger.log(picocolors_default()[code ? 'red' : 'yellow'](`No test files found, exiting with code ${code}.`));
|
|
247
278
|
process.exitCode = code;
|
|
248
279
|
}
|
|
249
280
|
if ('all' === mode) {
|
|
250
|
-
if (context.fileFilters?.length)
|
|
281
|
+
if (context.fileFilters?.length) logger_logger.log(picocolors_default().gray('filter: '), context.fileFilters.join(picocolors_default().gray(', ')));
|
|
251
282
|
context.projects.forEach((p)=>{
|
|
252
283
|
if (context.projects.length > 1) {
|
|
253
|
-
|
|
254
|
-
|
|
284
|
+
logger_logger.log('');
|
|
285
|
+
logger_logger.log(picocolors_default().gray('project:'), p.name);
|
|
255
286
|
}
|
|
256
|
-
|
|
257
|
-
|
|
287
|
+
logger_logger.log(picocolors_default().gray('include:'), p.normalizedConfig.include.join(picocolors_default().gray(', ')));
|
|
288
|
+
logger_logger.log(picocolors_default().gray('exclude:'), p.normalizedConfig.exclude.patterns.join(picocolors_default().gray(', ')));
|
|
258
289
|
});
|
|
259
290
|
}
|
|
260
291
|
}
|
|
261
|
-
const isFailure = results.some((r)=>'fail' === r.status);
|
|
292
|
+
const isFailure = results.some((r)=>'fail' === r.status) || errors.length;
|
|
262
293
|
if (isFailure) process.exitCode = 1;
|
|
263
294
|
for (const reporter of reporters)await reporter.onTestRunEnd?.({
|
|
264
295
|
results: context.reporterResults.results,
|
|
265
296
|
testResults: context.reporterResults.testResults,
|
|
297
|
+
unhandledErrors: errors,
|
|
266
298
|
snapshotSummary: snapshotManager.summary,
|
|
267
299
|
duration,
|
|
268
300
|
getSourcemap: async (name)=>{
|
|
@@ -282,20 +314,21 @@ async function runTests(context) {
|
|
|
282
314
|
}
|
|
283
315
|
if (isFailure) {
|
|
284
316
|
const bail = context.normalizedConfig.bail;
|
|
285
|
-
if (bail && context.stateManager.getCountOfFailedTests() >= bail)
|
|
317
|
+
if (bail && context.stateManager.getCountOfFailedTests() >= bail) logger_logger.log(picocolors_default().yellow(`Test run aborted due to reaching the bail limit of ${bail} failed test(s).`));
|
|
286
318
|
}
|
|
287
319
|
};
|
|
288
320
|
if ('watch' === command) {
|
|
289
321
|
const enableCliShortcuts = isCliShortcutsEnabled();
|
|
290
322
|
const afterTestsWatchRun = ()=>{
|
|
291
|
-
|
|
292
|
-
if (enableCliShortcuts) if (snapshotManager.summary.unmatched)
|
|
293
|
-
else
|
|
323
|
+
logger_logger.log(picocolors_default().green(' Waiting for file changes...'));
|
|
324
|
+
if (enableCliShortcuts) if (snapshotManager.summary.unmatched) logger_logger.log(` ${picocolors_default().dim('press')} ${picocolors_default().yellow(picocolors_default().bold('u'))} ${picocolors_default().dim('to update snapshot')}${picocolors_default().dim(', press')} ${picocolors_default().bold('h')} ${picocolors_default().dim('to show help')}\n`);
|
|
325
|
+
else logger_logger.log(` ${picocolors_default().dim('press')} ${picocolors_default().bold('h')} ${picocolors_default().dim('to show help')}${picocolors_default().dim(', press')} ${picocolors_default().bold('q')} ${picocolors_default().dim('to quit')}\n`);
|
|
294
326
|
};
|
|
295
327
|
const { onBeforeRestart } = await import("./0~588.js").then((mod)=>({
|
|
296
328
|
onBeforeRestart: mod.onBeforeRestart
|
|
297
329
|
}));
|
|
298
330
|
onBeforeRestart(async ()=>{
|
|
331
|
+
await runGlobalTeardown();
|
|
299
332
|
await pool.close();
|
|
300
333
|
await closeServer();
|
|
301
334
|
});
|
|
@@ -330,20 +363,20 @@ async function runTests(context) {
|
|
|
330
363
|
runWithTestNamePattern: async (pattern)=>{
|
|
331
364
|
clearScreen();
|
|
332
365
|
context.normalizedConfig.testNamePattern = pattern;
|
|
333
|
-
if (pattern)
|
|
334
|
-
else
|
|
366
|
+
if (pattern) logger_logger.log(`\n${picocolors_default().dim('Applied testNamePattern:')} ${picocolors_default().bold(pattern)}\n`);
|
|
367
|
+
else logger_logger.log(`\n${picocolors_default().dim('Cleared testNamePattern filter')}\n`);
|
|
335
368
|
snapshotManager.clear();
|
|
336
369
|
await run();
|
|
337
370
|
afterTestsWatchRun();
|
|
338
371
|
},
|
|
339
372
|
runWithFileFilters: async (filters)=>{
|
|
340
373
|
clearScreen();
|
|
341
|
-
if (filters && filters.length > 0)
|
|
342
|
-
else
|
|
374
|
+
if (filters && filters.length > 0) logger_logger.log(`\n${picocolors_default().dim('Applied file filters:')} ${picocolors_default().bold(filters.join(', '))}\n`);
|
|
375
|
+
else logger_logger.log(`\n${picocolors_default().dim('Cleared file filters')}\n`);
|
|
343
376
|
snapshotManager.clear();
|
|
344
377
|
context.fileFilters = filters;
|
|
345
378
|
const entries = await Promise.all(projects.map(async (p)=>globTestSourceEntries(p.environmentName))).then((entries)=>entries.reduce((acc, entry)=>acc.concat(...Object.values(entry)), []));
|
|
346
|
-
if (!entries.length) return void
|
|
379
|
+
if (!entries.length) return void logger_logger.log(filters ? picocolors_default().yellow(`\nNo matching test files to run with current file filters: ${filters.join(',')}\n`) : picocolors_default().yellow('\nNo matching test files to run.\n'));
|
|
347
380
|
await run({
|
|
348
381
|
fileFilters: entries
|
|
349
382
|
});
|
|
@@ -351,7 +384,7 @@ async function runTests(context) {
|
|
|
351
384
|
},
|
|
352
385
|
runFailedTests: async ()=>{
|
|
353
386
|
const failedTests = context.reporterResults.results.filter((result)=>'fail' === result.status).map((r)=>r.testPath);
|
|
354
|
-
if (!failedTests.length) return void
|
|
387
|
+
if (!failedTests.length) return void logger_logger.log(picocolors_default().yellow('\nNo failed tests were found that needed to be rerun.'));
|
|
355
388
|
clearScreen();
|
|
356
389
|
snapshotManager.clear();
|
|
357
390
|
await run({
|
|
@@ -361,7 +394,7 @@ async function runTests(context) {
|
|
|
361
394
|
afterTestsWatchRun();
|
|
362
395
|
},
|
|
363
396
|
updateSnapshot: async ()=>{
|
|
364
|
-
if (!snapshotManager.summary.unmatched) return void
|
|
397
|
+
if (!snapshotManager.summary.unmatched) return void logger_logger.log(picocolors_default().yellow('\nNo snapshots were found that needed to be updated.'));
|
|
365
398
|
const failedTests = context.reporterResults.results.filter((result)=>result.snapshotResult?.unmatched).map((r)=>r.testPath);
|
|
366
399
|
clearScreen();
|
|
367
400
|
const originalUpdateSnapshot = snapshotManager.options.updateSnapshot;
|
|
@@ -381,9 +414,12 @@ async function runTests(context) {
|
|
|
381
414
|
} else {
|
|
382
415
|
let isTeardown = false;
|
|
383
416
|
const unExpectedExit = (code)=>{
|
|
384
|
-
if (isTeardown)
|
|
417
|
+
if (isTeardown) logger_logger.log(picocolors_default().yellow(`Rstest exited unexpectedly with code ${code}, this is likely caused by test environment teardown.`));
|
|
385
418
|
else {
|
|
386
|
-
|
|
419
|
+
logger_logger.log(picocolors_default().red(`Rstest exited unexpectedly with code ${code}, terminating test run.`));
|
|
420
|
+
runGlobalTeardown().catch((error)=>{
|
|
421
|
+
logger_logger.log(picocolors_default().red(`Error in global teardown: ${error}`));
|
|
422
|
+
});
|
|
387
423
|
process.exitCode = 1;
|
|
388
424
|
}
|
|
389
425
|
};
|
|
@@ -392,6 +428,7 @@ async function runTests(context) {
|
|
|
392
428
|
isTeardown = true;
|
|
393
429
|
await pool.close();
|
|
394
430
|
await closeServer();
|
|
431
|
+
await runGlobalTeardown();
|
|
395
432
|
process.off('exit', unExpectedExit);
|
|
396
433
|
}
|
|
397
434
|
}
|
package/dist/0~255.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import "./
|
|
5
|
-
const external_node_fs_ = __webpack_require__("
|
|
4
|
+
import "./664.js";
|
|
5
|
+
const external_node_fs_ = __webpack_require__("fs");
|
|
6
6
|
const pluginCoverageCore = (coverageOptions)=>({
|
|
7
7
|
name: 'rstest:coverage-core',
|
|
8
8
|
setup: (api)=>{
|
package/dist/0~403.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import { isDynamicPattern, glob
|
|
3
|
+
import { isDynamicPattern, glob } from "./157.js";
|
|
4
|
+
import { normalize, logger_logger } from "./278.js";
|
|
4
5
|
const getIncludedFiles = async (coverage, rootPath)=>{
|
|
5
6
|
const ignoredPatterns = coverage.exclude?.filter((item)=>isDynamicPattern(item) || item.startsWith(rootPath) || item.startsWith('./'));
|
|
6
7
|
const allFiles = await glob(coverage.include, {
|
|
@@ -27,7 +28,7 @@ async function generateCoverage(context, results, coverageProvider) {
|
|
|
27
28
|
let isTimeout = false;
|
|
28
29
|
const timeoutId = setTimeout(()=>{
|
|
29
30
|
isTimeout = true;
|
|
30
|
-
|
|
31
|
+
logger_logger.info('Generating coverage for untested files...');
|
|
31
32
|
}, 1000);
|
|
32
33
|
const allFiles = (await Promise.all(projects.map(async (p)=>{
|
|
33
34
|
const includedFiles = await getIncludedFiles(coverage, p.rootPath);
|
|
@@ -36,7 +37,7 @@ async function generateCoverage(context, results, coverageProvider) {
|
|
|
36
37
|
return includedFiles;
|
|
37
38
|
}))).flat();
|
|
38
39
|
clearTimeout(timeoutId);
|
|
39
|
-
if (isTimeout)
|
|
40
|
+
if (isTimeout) logger_logger.info('Coverage for untested files generated.');
|
|
40
41
|
finalCoverageMap.filter((file)=>allFiles.includes(normalize(file)));
|
|
41
42
|
}
|
|
42
43
|
await coverageProvider.generateReports(finalCoverageMap, coverage);
|
|
@@ -51,17 +52,17 @@ async function generateCoverage(context, results, coverageProvider) {
|
|
|
51
52
|
thresholds: coverage.thresholds
|
|
52
53
|
});
|
|
53
54
|
if (!thresholdResult.success) {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
logger_logger.log('');
|
|
56
|
+
logger_logger.log(thresholdResult.message);
|
|
56
57
|
process.exitCode = 1;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
} catch (error) {
|
|
60
|
-
|
|
61
|
+
logger_logger.error('Failed to generate coverage reports:', error);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
async function generateCoverageForUntestedFiles(environmentName, uncoveredFiles, coverageMap, coverageProvider) {
|
|
64
|
-
if (!coverageProvider.generateCoverageForUntestedFiles) return void
|
|
65
|
+
if (!coverageProvider.generateCoverageForUntestedFiles) return void logger_logger.warn('Current coverage provider does not support generating coverage for untested files.');
|
|
65
66
|
const coverages = await coverageProvider.generateCoverageForUntestedFiles({
|
|
66
67
|
environmentName,
|
|
67
68
|
files: uncoveredFiles
|
package/dist/0~426.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
4
|
+
import "./157.js";
|
|
5
|
+
import "./664.js";
|
|
6
|
+
import { relative } from "./278.js";
|
|
5
7
|
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
|
|
6
8
|
var picomatch_default = /*#__PURE__*/ __webpack_require__.n(picomatch);
|
|
7
9
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -34,7 +36,7 @@ function checkThresholds({ coverageMap, thresholds, coverageProvider, rootPath }
|
|
|
34
36
|
if (THRESHOLD_KEYS.includes(key) || 'object' != typeof thresholds[key]) continue;
|
|
35
37
|
const globCoverageMap = coverageProvider.createCoverageMap();
|
|
36
38
|
const matcher = picomatch_default()(key);
|
|
37
|
-
const matchedFiles = allFiles.filter((file)=>matcher(
|
|
39
|
+
const matchedFiles = allFiles.filter((file)=>matcher(relative(rootPath, file)));
|
|
38
40
|
if (!matchedFiles.length) {
|
|
39
41
|
failedThresholds.push(`${picocolors_default().red('Error')}: coverage data for "${key}" was not found`);
|
|
40
42
|
continue;
|
|
@@ -57,7 +59,7 @@ function checkThresholds({ coverageMap, thresholds, coverageProvider, rootPath }
|
|
|
57
59
|
if (uncovered > -expected) errorMsg += `uncovered ${name} ${picocolors_default().red(`${uncovered}`)} exceeds maximum ${'global' === type ? 'global' : `"${type}"`} threshold allowed ${picocolors_default().yellow(`${-expected}`)}`;
|
|
58
60
|
} else if (actual.pct < expected) errorMsg += `coverage for ${name} ${picocolors_default().red(`${actual.pct}%`)} does not meet ${'global' === type ? 'global' : `"${type}"`} threshold ${picocolors_default().yellow(`${expected}%`)}`;
|
|
59
61
|
}
|
|
60
|
-
if (errorMsg) failedThresholds.push(`${picocolors_default().red('Error')}: ${file ? `${
|
|
62
|
+
if (errorMsg) failedThresholds.push(`${picocolors_default().red('Error')}: ${file ? `${relative(rootPath, file)} ` : ''}${errorMsg}`);
|
|
61
63
|
};
|
|
62
64
|
thresholdGroup.forEach(({ name, coverageMap, ...thresholds })=>{
|
|
63
65
|
const summaries = thresholds.perFile ? coverageMap.files().map((file)=>({
|
package/dist/0~583.js
CHANGED
|
@@ -4,7 +4,8 @@ import 'module';
|
|
|
4
4
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
5
|
import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "fs/promises";
|
|
6
6
|
import { Readable } from "node:stream";
|
|
7
|
-
import
|
|
7
|
+
import "./664.js";
|
|
8
|
+
import { readdir as promises_readdir, lstat as promises_lstat, promises_stat as promises_promises_stat, realpath as external_node_fs_promises_realpath } from "./157.js";
|
|
8
9
|
import { EventEmitter } from "./131.js";
|
|
9
10
|
const external_node_path_ = __webpack_require__("node:path");
|
|
10
11
|
const EntryTypes = {
|
|
@@ -220,7 +221,7 @@ function readdirp(root, options = {}) {
|
|
|
220
221
|
options.root = root;
|
|
221
222
|
return new ReaddirpStream(options);
|
|
222
223
|
}
|
|
223
|
-
const external_node_fs_ = __webpack_require__("
|
|
224
|
+
const external_node_fs_ = __webpack_require__("fs");
|
|
224
225
|
const external_node_os_ = __webpack_require__("node:os");
|
|
225
226
|
const STR_DATA = 'data';
|
|
226
227
|
const STR_END = 'end';
|
package/dist/0~588.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
4
|
+
import "./664.js";
|
|
5
5
|
import { runRest } from "./131.js";
|
|
6
|
+
import { isTTY } from "./157.js";
|
|
7
|
+
import { logger_logger } from "./278.js";
|
|
6
8
|
const GLOB_REGEX = /[*?{}[\]()!@+|]/;
|
|
7
9
|
const isGlob = (str)=>GLOB_REGEX.test(str);
|
|
8
10
|
async function createChokidar(pathOrGlobs, root, options) {
|
|
@@ -16,7 +18,7 @@ async function createChokidar(pathOrGlobs, root, options) {
|
|
|
16
18
|
return false;
|
|
17
19
|
});
|
|
18
20
|
if (globPatterns.length) {
|
|
19
|
-
const { glob } = await import("./
|
|
21
|
+
const { glob } = await import("./157.js").then((mod)=>({
|
|
20
22
|
glob: mod.glob
|
|
21
23
|
}));
|
|
22
24
|
const files = await glob(globPatterns, {
|
|
@@ -41,8 +43,8 @@ const beforeRestart = async ({ filePath, root, clear = true })=>{
|
|
|
41
43
|
if (clear) clearConsole();
|
|
42
44
|
if (filePath) {
|
|
43
45
|
const filename = external_node_path_["default"].relative(root, filePath);
|
|
44
|
-
|
|
45
|
-
} else
|
|
46
|
+
logger_logger.info(`restarting Rstest as ${picocolors_default().yellow(filename)} changed\n`);
|
|
47
|
+
} else logger_logger.info('restarting Rstest...\n');
|
|
46
48
|
for (const cleaner of cleaners)await cleaner();
|
|
47
49
|
cleaners = [];
|
|
48
50
|
};
|
|
@@ -82,7 +84,7 @@ async function watchFilesForRestart({ rstest, watchOptions, options, filters })
|
|
|
82
84
|
filePath
|
|
83
85
|
});
|
|
84
86
|
if (restarted) await watcher.close();
|
|
85
|
-
else
|
|
87
|
+
else logger_logger.error('Restart failed');
|
|
86
88
|
restarting = false;
|
|
87
89
|
};
|
|
88
90
|
watcher.on('add', onChange);
|
package/dist/0~62.js
CHANGED
package/dist/0~634.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
5
|
-
import { prepareRsbuild, createPool, createRsbuildServer } from "./0~
|
|
6
|
-
|
|
4
|
+
import "./664.js";
|
|
5
|
+
import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
|
|
6
|
+
import { getTestEntries, getSetupFiles, getTaskNameWithPrefix, prettyTestPath, ROOT_SUITE_NAME, bgColor } from "./157.js";
|
|
7
|
+
import { logger_logger } from "./278.js";
|
|
8
|
+
const external_node_fs_ = __webpack_require__("fs");
|
|
7
9
|
const external_node_path_ = __webpack_require__("node:path");
|
|
8
10
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
9
11
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
@@ -15,9 +17,17 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
15
17
|
getSetupFiles(setupFiles, rootPath)
|
|
16
18
|
];
|
|
17
19
|
}));
|
|
18
|
-
const
|
|
20
|
+
const globalSetupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
21
|
+
const { environmentName, rootPath, normalizedConfig: { globalSetup } } = project;
|
|
22
|
+
return [
|
|
23
|
+
environmentName,
|
|
24
|
+
getSetupFiles(globalSetup, rootPath)
|
|
25
|
+
];
|
|
26
|
+
}));
|
|
27
|
+
const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles);
|
|
19
28
|
const { getRsbuildStats, closeServer } = await createRsbuildServer({
|
|
20
29
|
globTestSourceEntries,
|
|
30
|
+
globalSetupFiles,
|
|
21
31
|
inspectedConfig: {
|
|
22
32
|
...context.normalizedConfig,
|
|
23
33
|
projects: context.projects.map((p)=>p.normalizedConfig)
|
|
@@ -31,9 +41,28 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
31
41
|
});
|
|
32
42
|
const updateSnapshot = context.snapshotManager.options.updateSnapshot;
|
|
33
43
|
const returns = await Promise.all(context.projects.map(async (project)=>{
|
|
34
|
-
const { entries, setupEntries, getSourceMaps, getAssetFiles, assetNames } = await getRsbuildStats({
|
|
44
|
+
const { entries, setupEntries, globalSetupEntries, getSourceMaps, getAssetFiles, assetNames } = await getRsbuildStats({
|
|
35
45
|
environmentName: project.environmentName
|
|
36
46
|
});
|
|
47
|
+
if (entries.length && globalSetupEntries.length && !project._globalSetups) {
|
|
48
|
+
project._globalSetups = true;
|
|
49
|
+
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
50
|
+
const assetFiles = await getAssetFiles(files);
|
|
51
|
+
const sourceMaps = await getSourceMaps(files);
|
|
52
|
+
const { success, errors } = await runGlobalSetup({
|
|
53
|
+
globalSetupEntries,
|
|
54
|
+
assetFiles,
|
|
55
|
+
sourceMaps,
|
|
56
|
+
interopDefault: true,
|
|
57
|
+
outputModule: project.outputModule
|
|
58
|
+
});
|
|
59
|
+
if (!success) return {
|
|
60
|
+
list: [],
|
|
61
|
+
errors,
|
|
62
|
+
assetNames,
|
|
63
|
+
getSourceMaps: ()=>null
|
|
64
|
+
};
|
|
65
|
+
}
|
|
37
66
|
const list = await pool.collectTests({
|
|
38
67
|
entries,
|
|
39
68
|
setupEntries,
|
|
@@ -50,6 +79,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
50
79
|
}));
|
|
51
80
|
return {
|
|
52
81
|
list: returns.flatMap((r)=>r.list),
|
|
82
|
+
errors: returns.flatMap((r)=>r.errors || []),
|
|
53
83
|
getSourceMap: async (name)=>{
|
|
54
84
|
const resource = returns.find((r)=>r.assetNames.includes(name));
|
|
55
85
|
return (await resource?.getSourceMaps([
|
|
@@ -57,6 +87,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
57
87
|
]))?.[name];
|
|
58
88
|
},
|
|
59
89
|
close: async ()=>{
|
|
90
|
+
await runGlobalTeardown();
|
|
60
91
|
await closeServer();
|
|
61
92
|
await pool.close();
|
|
62
93
|
}
|
|
@@ -74,11 +105,12 @@ const collectTestFiles = async ({ context, globTestSourceEntries })=>{
|
|
|
74
105
|
}
|
|
75
106
|
return {
|
|
76
107
|
close: async ()=>{},
|
|
108
|
+
errors: [],
|
|
77
109
|
list,
|
|
78
110
|
getSourceMap: async (_name)=>null
|
|
79
111
|
};
|
|
80
112
|
};
|
|
81
|
-
async function listTests(context, { filesOnly, json }) {
|
|
113
|
+
async function listTests(context, { filesOnly, json, printLocation, includeSuites }) {
|
|
82
114
|
const { rootPath } = context;
|
|
83
115
|
const testEntries = {};
|
|
84
116
|
const globTestSourceEntries = async (name)=>{
|
|
@@ -95,7 +127,7 @@ async function listTests(context, { filesOnly, json }) {
|
|
|
95
127
|
testEntries[name] = entries;
|
|
96
128
|
return entries;
|
|
97
129
|
};
|
|
98
|
-
const { list, close, getSourceMap } = filesOnly ? await collectTestFiles({
|
|
130
|
+
const { list, close, getSourceMap, errors = [] } = filesOnly ? await collectTestFiles({
|
|
99
131
|
context,
|
|
100
132
|
globTestSourceEntries
|
|
101
133
|
}) : await collectTests({
|
|
@@ -108,18 +140,16 @@ async function listTests(context, { filesOnly, json }) {
|
|
|
108
140
|
'skip',
|
|
109
141
|
'todo'
|
|
110
142
|
].includes(test.runMode)) return;
|
|
111
|
-
if ('case' === test.type
|
|
143
|
+
if ('case' === test.type || includeSuites && 'suite' === test.type && test.name !== ROOT_SUITE_NAME) tests.push({
|
|
112
144
|
file: test.testPath,
|
|
113
145
|
name: getTaskNameWithPrefix(test),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
file: test.testPath,
|
|
118
|
-
name: getTaskNameWithPrefix(test)
|
|
146
|
+
location: test.location,
|
|
147
|
+
type: test.type,
|
|
148
|
+
project: showProject ? test.project : void 0
|
|
119
149
|
});
|
|
120
|
-
|
|
150
|
+
if ('suite' === test.type) for (const child of test.tests)traverseTests(child);
|
|
121
151
|
};
|
|
122
|
-
const hasError = list.some((file)=>file.errors?.length);
|
|
152
|
+
const hasError = list.some((file)=>file.errors?.length) || errors.length;
|
|
123
153
|
const showProject = context.projects.length > 1;
|
|
124
154
|
if (hasError) {
|
|
125
155
|
const { printError } = await import("./131.js").then((mod)=>({
|
|
@@ -129,24 +159,38 @@ async function listTests(context, { filesOnly, json }) {
|
|
|
129
159
|
for (const file of list){
|
|
130
160
|
const relativePath = (0, external_node_path_.relative)(rootPath, file.testPath);
|
|
131
161
|
if (file.errors?.length) {
|
|
132
|
-
|
|
162
|
+
logger_logger.log(`${bgColor('bgRed', ' FAIL ')} ${relativePath}`);
|
|
133
163
|
for (const error of file.errors)await printError(error, async (name)=>{
|
|
134
164
|
const sourceMap = await getSourceMap(name);
|
|
135
165
|
return sourceMap ? JSON.parse(sourceMap) : null;
|
|
136
166
|
}, rootPath);
|
|
137
167
|
}
|
|
138
168
|
}
|
|
169
|
+
if (errors.length) {
|
|
170
|
+
const { printError } = await import("./131.js").then((mod)=>({
|
|
171
|
+
printError: mod.error_printError
|
|
172
|
+
}));
|
|
173
|
+
for (const error of errors || []){
|
|
174
|
+
logger_logger.stderr(bgColor('bgRed', ' Unhandled Error '));
|
|
175
|
+
await printError(error, async (name)=>{
|
|
176
|
+
const sourceMap = await getSourceMap(name);
|
|
177
|
+
return sourceMap ? JSON.parse(sourceMap) : null;
|
|
178
|
+
}, rootPath);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
139
181
|
await close();
|
|
140
|
-
return;
|
|
182
|
+
return list;
|
|
141
183
|
}
|
|
142
184
|
for (const file of list){
|
|
143
185
|
if (filesOnly) {
|
|
144
186
|
if (showProject) tests.push({
|
|
145
187
|
file: file.testPath,
|
|
146
|
-
project: file.project
|
|
188
|
+
project: file.project,
|
|
189
|
+
type: 'file'
|
|
147
190
|
});
|
|
148
191
|
else tests.push({
|
|
149
|
-
file: file.testPath
|
|
192
|
+
file: file.testPath,
|
|
193
|
+
type: 'file'
|
|
150
194
|
});
|
|
151
195
|
continue;
|
|
152
196
|
}
|
|
@@ -160,11 +204,13 @@ async function listTests(context, { filesOnly, json }) {
|
|
|
160
204
|
recursive: true
|
|
161
205
|
});
|
|
162
206
|
(0, external_node_fs_.writeFileSync)(jsonPath, content);
|
|
163
|
-
} else
|
|
207
|
+
} else logger_logger.log(content);
|
|
164
208
|
} else for (const test of tests){
|
|
165
|
-
|
|
166
|
-
|
|
209
|
+
let shortPath = (0, external_node_path_.relative)(rootPath, test.file);
|
|
210
|
+
if (test.location && printLocation) shortPath = `${shortPath}:${test.location.line}:${test.location.column}`;
|
|
211
|
+
logger_logger.log(test.name ? `${picocolors_default().dim(`${shortPath} > `)}${test.name}` : prettyTestPath(shortPath));
|
|
167
212
|
}
|
|
168
213
|
await close();
|
|
214
|
+
return list;
|
|
169
215
|
}
|
|
170
216
|
export { listTests };
|
package/dist/0~809.js
CHANGED
package/dist/0~835.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import {
|
|
5
|
-
import { pathToFileURL } from "./
|
|
4
|
+
import { createRequire as external_node_module_createRequire } from "./664.js";
|
|
5
|
+
import { pathToFileURL } from "./198.js";
|
|
6
6
|
import { node_vm, asModule, shouldInterop, interopModule } from "./0~346.js";
|
|
7
|
+
import { posix, logger_logger } from "./278.js";
|
|
7
8
|
const external_node_path_ = __webpack_require__("node:path");
|
|
8
9
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
9
10
|
const createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
@@ -28,7 +29,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
28
29
|
interopDefault
|
|
29
30
|
});
|
|
30
31
|
} catch (err) {
|
|
31
|
-
|
|
32
|
+
logger_logger.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
32
33
|
}
|
|
33
34
|
const resolved = _require.resolve(id);
|
|
34
35
|
return _require(resolved);
|