@rstest/core 0.7.3 → 0.7.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/dist/0~130.js +2 -1
- package/dist/0~151.js +18 -21
- package/dist/0~173.js +49 -7
- package/dist/0~255.js +1 -1
- package/dist/0~403.js +2 -1
- package/dist/0~426.js +5 -3
- package/dist/0~583.js +3 -2
- package/dist/0~588.js +5 -3
- package/dist/0~62.js +1 -1
- package/dist/0~634.js +55 -7
- package/dist/0~809.js +1 -1
- package/dist/0~835.js +5 -3
- package/dist/{0~122.js → 0~89.js} +178 -47
- package/dist/0~919.js +1 -1
- package/dist/0~923.js +4 -3
- package/dist/0~973.js +50 -0
- package/dist/131.js +42 -22
- package/dist/{946.js → 157.js} +10 -890
- package/dist/198.js +4 -0
- package/dist/{404.js → 216.js} +1 -2
- package/dist/278.js +765 -0
- package/dist/554.js +5 -6714
- package/dist/693.js +91 -0
- package/dist/734.js +5 -3
- package/dist/881.js +4 -0
- package/dist/913.js +6718 -0
- package/dist/globalSetupWorker.d.ts +9 -0
- package/dist/globalSetupWorker.js +115 -0
- package/dist/index.d.ts +168 -21
- package/dist/index.js +1 -1
- package/dist/worker.d.ts +166 -21
- package/package.json +3 -2
- /package/dist/{554.js.LICENSE.txt → 913.js.LICENSE.txt} +0 -0
package/dist/0~130.js
CHANGED
|
@@ -3,7 +3,8 @@ import 'module';
|
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
4
|
import { AssertionError, strict } from "node:assert";
|
|
5
5
|
import { Console } from "node:console";
|
|
6
|
-
import
|
|
6
|
+
import "./693.js";
|
|
7
|
+
import { prettyTime } from "./157.js";
|
|
7
8
|
const external_node_util_ = __webpack_require__("node:util");
|
|
8
9
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
9
10
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
package/dist/0~151.js
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
import 'module';
|
|
3
3
|
/*#__PURE__*/ import.meta.url;
|
|
4
4
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import "./693.js";
|
|
6
|
+
import { resolve as pathe_M_eThtNZ_resolve } from "./278.js";
|
|
7
|
+
import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, ROOT_SUITE_NAME } from "./157.js";
|
|
8
|
+
import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./913.js";
|
|
9
|
+
import { fileURLToPath } from "./198.js";
|
|
8
10
|
import { parse } from "./672.js";
|
|
11
|
+
import "./554.js";
|
|
9
12
|
__webpack_require__.add({
|
|
10
13
|
"../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
11
14
|
var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
|
|
@@ -12200,9 +12203,11 @@ class TestRunner {
|
|
|
12200
12203
|
let result;
|
|
12201
12204
|
this.beforeEach(test, state, api);
|
|
12202
12205
|
const cleanups = [];
|
|
12206
|
+
const fixtureCleanups = await this.beforeRunTest(test, snapshotClient.getSnapshotState(testPath));
|
|
12207
|
+
cleanups.push(...fixtureCleanups);
|
|
12203
12208
|
try {
|
|
12204
12209
|
for (const fn of parentHooks.beforeEachListeners){
|
|
12205
|
-
const cleanupFn = await fn();
|
|
12210
|
+
const cleanupFn = await fn(test.context);
|
|
12206
12211
|
cleanupFn && cleanups.push(cleanupFn);
|
|
12207
12212
|
}
|
|
12208
12213
|
} catch (error) {
|
|
@@ -12217,8 +12222,6 @@ class TestRunner {
|
|
|
12217
12222
|
};
|
|
12218
12223
|
}
|
|
12219
12224
|
if (result?.status !== 'fail') if (test.fails) try {
|
|
12220
|
-
const fixtureCleanups = await this.beforeRunTest(test, snapshotClient.getSnapshotState(testPath));
|
|
12221
|
-
cleanups.push(...fixtureCleanups);
|
|
12222
12225
|
await test.fn?.(test.context);
|
|
12223
12226
|
this.afterRunTest(test);
|
|
12224
12227
|
result = {
|
|
@@ -12245,8 +12248,6 @@ class TestRunner {
|
|
|
12245
12248
|
};
|
|
12246
12249
|
}
|
|
12247
12250
|
else try {
|
|
12248
|
-
const fixtureCleanups = await this.beforeRunTest(test, snapshotClient.getSnapshotState(testPath));
|
|
12249
|
-
cleanups.push(...fixtureCleanups);
|
|
12250
12251
|
if (test.fn) {
|
|
12251
12252
|
const fn = wrapTimeout({
|
|
12252
12253
|
name: 'test',
|
|
@@ -12284,12 +12285,9 @@ class TestRunner {
|
|
|
12284
12285
|
const afterEachFns = [
|
|
12285
12286
|
...parentHooks.afterEachListeners || []
|
|
12286
12287
|
].reverse().concat(cleanups).concat(test.onFinished);
|
|
12288
|
+
test.context.task.result = result;
|
|
12287
12289
|
try {
|
|
12288
|
-
for (const fn of afterEachFns)await fn(
|
|
12289
|
-
task: {
|
|
12290
|
-
result
|
|
12291
|
-
}
|
|
12292
|
-
});
|
|
12290
|
+
for (const fn of afterEachFns)await fn(test.context);
|
|
12293
12291
|
} catch (error) {
|
|
12294
12292
|
result.status = 'fail';
|
|
12295
12293
|
result.errors ??= [];
|
|
@@ -12298,11 +12296,7 @@ class TestRunner {
|
|
|
12298
12296
|
if ('fail' === result.status) for (const fn of [
|
|
12299
12297
|
...test.onFailed
|
|
12300
12298
|
].reverse())try {
|
|
12301
|
-
await fn(
|
|
12302
|
-
task: {
|
|
12303
|
-
result
|
|
12304
|
-
}
|
|
12305
|
-
});
|
|
12299
|
+
await fn(test.context);
|
|
12306
12300
|
} catch (error) {
|
|
12307
12301
|
result.errors ??= [];
|
|
12308
12302
|
result.errors.push(...formatTestError(error));
|
|
@@ -12511,12 +12505,15 @@ class TestRunner {
|
|
|
12511
12505
|
if (unstubEnvs) api.rstest.unstubAllEnvs();
|
|
12512
12506
|
if (unstubGlobals) api.rstest.unstubAllGlobals();
|
|
12513
12507
|
}
|
|
12514
|
-
createTestContext() {
|
|
12508
|
+
createTestContext(test) {
|
|
12515
12509
|
const context = ()=>{
|
|
12516
12510
|
throw new Error('done() callback is deprecated, use promise instead');
|
|
12517
12511
|
};
|
|
12518
12512
|
let _expect;
|
|
12519
12513
|
const current = this._test;
|
|
12514
|
+
context.task = {
|
|
12515
|
+
name: test.name
|
|
12516
|
+
};
|
|
12520
12517
|
Object.defineProperty(context, 'expect', {
|
|
12521
12518
|
get: ()=>{
|
|
12522
12519
|
if (!_expect) _expect = createExpect({
|
|
@@ -12572,7 +12569,7 @@ class TestRunner {
|
|
|
12572
12569
|
snapshotState,
|
|
12573
12570
|
currentTestName: getTaskNameWithPrefix(test)
|
|
12574
12571
|
}, globalThis[GLOBAL_EXPECT]);
|
|
12575
|
-
const context = this.createTestContext();
|
|
12572
|
+
const context = this.createTestContext(test);
|
|
12576
12573
|
const { cleanups } = await handleFixtures(test, context);
|
|
12577
12574
|
Object.defineProperty(test, 'context', {
|
|
12578
12575
|
value: context,
|
|
@@ -12588,7 +12585,7 @@ class TestRunner {
|
|
|
12588
12585
|
if (true === isExpectingAssertions && 0 === assertionCalls) throw isExpectingAssertionsError;
|
|
12589
12586
|
}
|
|
12590
12587
|
}
|
|
12591
|
-
const external_node_path_ = __webpack_require__("path");
|
|
12588
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
12592
12589
|
class RunnerRuntime {
|
|
12593
12590
|
tests = [];
|
|
12594
12591
|
_currentTest = [];
|
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 "./693.js";
|
|
5
|
+
import { getTestEntries, 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');
|
|
@@ -166,6 +168,9 @@ async function runTests(context) {
|
|
|
166
168
|
});
|
|
167
169
|
return entries;
|
|
168
170
|
};
|
|
171
|
+
const { getSetupFiles } = await import("./0~973.js").then((mod)=>({
|
|
172
|
+
getSetupFiles: mod.getSetupFiles
|
|
173
|
+
}));
|
|
169
174
|
const setupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
170
175
|
const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
|
|
171
176
|
return [
|
|
@@ -173,17 +178,27 @@ async function runTests(context) {
|
|
|
173
178
|
getSetupFiles(setupFiles, rootPath)
|
|
174
179
|
];
|
|
175
180
|
}));
|
|
176
|
-
const
|
|
181
|
+
const globalSetupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
182
|
+
const { environmentName, rootPath, normalizedConfig: { globalSetup } } = project;
|
|
183
|
+
return [
|
|
184
|
+
environmentName,
|
|
185
|
+
getSetupFiles(globalSetup, rootPath)
|
|
186
|
+
];
|
|
187
|
+
}));
|
|
188
|
+
const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles);
|
|
189
|
+
const isWatchMode = 'watch' === command;
|
|
177
190
|
const { getRsbuildStats, closeServer } = await createRsbuildServer({
|
|
178
191
|
inspectedConfig: {
|
|
179
192
|
...context.normalizedConfig,
|
|
180
193
|
projects: context.projects.map((p)=>p.normalizedConfig)
|
|
181
194
|
},
|
|
182
|
-
|
|
195
|
+
isWatchMode,
|
|
196
|
+
globTestSourceEntries: isWatchMode ? globTestSourceEntries : async (name)=>{
|
|
183
197
|
if (entriesCache.has(name)) return entriesCache.get(name).entries;
|
|
184
198
|
return globTestSourceEntries(name);
|
|
185
199
|
},
|
|
186
200
|
setupFiles,
|
|
201
|
+
globalSetupFiles,
|
|
187
202
|
rsbuildInstance,
|
|
188
203
|
rootPath
|
|
189
204
|
});
|
|
@@ -200,11 +215,31 @@ async function runTests(context) {
|
|
|
200
215
|
const currentDeletedEntries = [];
|
|
201
216
|
context.stateManager.reset();
|
|
202
217
|
const returns = await Promise.all(context.projects.map(async (p)=>{
|
|
203
|
-
const { assetNames, entries, setupEntries, getAssetFiles, getSourceMaps, affectedEntries, deletedEntries } = await getRsbuildStats({
|
|
218
|
+
const { assetNames, entries, setupEntries, globalSetupEntries, getAssetFiles, getSourceMaps, affectedEntries, deletedEntries } = await getRsbuildStats({
|
|
204
219
|
environmentName: p.environmentName,
|
|
205
220
|
fileFilters
|
|
206
221
|
});
|
|
207
222
|
testStart ??= Date.now();
|
|
223
|
+
if (entries.length && globalSetupEntries.length && !p._globalSetups) {
|
|
224
|
+
p._globalSetups = true;
|
|
225
|
+
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
226
|
+
const assetFiles = await getAssetFiles(files);
|
|
227
|
+
const sourceMaps = await getSourceMaps(files);
|
|
228
|
+
const { success, errors } = await runGlobalSetup({
|
|
229
|
+
globalSetupEntries,
|
|
230
|
+
assetFiles,
|
|
231
|
+
sourceMaps,
|
|
232
|
+
interopDefault: true,
|
|
233
|
+
outputModule: p.outputModule
|
|
234
|
+
});
|
|
235
|
+
if (!success) return {
|
|
236
|
+
results: [],
|
|
237
|
+
testResults: [],
|
|
238
|
+
errors,
|
|
239
|
+
assetNames,
|
|
240
|
+
getSourceMaps: ()=>null
|
|
241
|
+
};
|
|
242
|
+
}
|
|
208
243
|
currentDeletedEntries.push(...deletedEntries);
|
|
209
244
|
let finalEntries = entries;
|
|
210
245
|
if ('on-demand' === mode) {
|
|
@@ -237,8 +272,9 @@ async function runTests(context) {
|
|
|
237
272
|
};
|
|
238
273
|
const results = returns.flatMap((r)=>r.results);
|
|
239
274
|
const testResults = returns.flatMap((r)=>r.testResults);
|
|
275
|
+
const errors = returns.flatMap((r)=>r.errors || []);
|
|
240
276
|
context.updateReporterResultState(results, testResults, currentDeletedEntries);
|
|
241
|
-
if (0 === results.length) {
|
|
277
|
+
if (0 === results.length && !errors.length) {
|
|
242
278
|
if ('watch' === command) if ('on-demand' === mode) logger_logger.log(picocolors_default().yellow('No test files need re-run.'));
|
|
243
279
|
else logger_logger.log(picocolors_default().yellow('No test files found.'));
|
|
244
280
|
else {
|
|
@@ -258,11 +294,12 @@ async function runTests(context) {
|
|
|
258
294
|
});
|
|
259
295
|
}
|
|
260
296
|
}
|
|
261
|
-
const isFailure = results.some((r)=>'fail' === r.status);
|
|
297
|
+
const isFailure = results.some((r)=>'fail' === r.status) || errors.length;
|
|
262
298
|
if (isFailure) process.exitCode = 1;
|
|
263
299
|
for (const reporter of reporters)await reporter.onTestRunEnd?.({
|
|
264
300
|
results: context.reporterResults.results,
|
|
265
301
|
testResults: context.reporterResults.testResults,
|
|
302
|
+
unhandledErrors: errors,
|
|
266
303
|
snapshotSummary: snapshotManager.summary,
|
|
267
304
|
duration,
|
|
268
305
|
getSourcemap: async (name)=>{
|
|
@@ -296,6 +333,7 @@ async function runTests(context) {
|
|
|
296
333
|
onBeforeRestart: mod.onBeforeRestart
|
|
297
334
|
}));
|
|
298
335
|
onBeforeRestart(async ()=>{
|
|
336
|
+
await runGlobalTeardown();
|
|
299
337
|
await pool.close();
|
|
300
338
|
await closeServer();
|
|
301
339
|
});
|
|
@@ -384,6 +422,9 @@ async function runTests(context) {
|
|
|
384
422
|
if (isTeardown) logger_logger.log(picocolors_default().yellow(`Rstest exited unexpectedly with code ${code}, this is likely caused by test environment teardown.`));
|
|
385
423
|
else {
|
|
386
424
|
logger_logger.log(picocolors_default().red(`Rstest exited unexpectedly with code ${code}, terminating test run.`));
|
|
425
|
+
runGlobalTeardown().catch((error)=>{
|
|
426
|
+
logger_logger.log(picocolors_default().red(`Error in global teardown: ${error}`));
|
|
427
|
+
});
|
|
387
428
|
process.exitCode = 1;
|
|
388
429
|
}
|
|
389
430
|
};
|
|
@@ -392,6 +433,7 @@ async function runTests(context) {
|
|
|
392
433
|
isTeardown = true;
|
|
393
434
|
await pool.close();
|
|
394
435
|
await closeServer();
|
|
436
|
+
await runGlobalTeardown();
|
|
395
437
|
process.off('exit', unExpectedExit);
|
|
396
438
|
}
|
|
397
439
|
}
|
package/dist/0~255.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import "./
|
|
4
|
+
import "./693.js";
|
|
5
5
|
const external_node_fs_ = __webpack_require__("node:fs");
|
|
6
6
|
const pluginCoverageCore = (coverageOptions)=>({
|
|
7
7
|
name: 'rstest:coverage-core',
|
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, {
|
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 "./693.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,9 +4,10 @@ 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 "./693.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
|
-
const external_node_path_ = __webpack_require__("path");
|
|
10
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
10
11
|
const EntryTypes = {
|
|
11
12
|
FILE_TYPE: 'files',
|
|
12
13
|
DIR_TYPE: 'directories',
|
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 "./693.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, {
|
|
@@ -27,7 +29,7 @@ async function createChokidar(pathOrGlobs, root, options) {
|
|
|
27
29
|
}
|
|
28
30
|
return chokidar.watch(Array.from(watchFiles), options);
|
|
29
31
|
}
|
|
30
|
-
const external_node_path_ = __webpack_require__("path");
|
|
32
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
31
33
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
32
34
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
33
35
|
let cleaners = [];
|
package/dist/0~62.js
CHANGED
package/dist/0~634.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
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~
|
|
4
|
+
import "./693.js";
|
|
5
|
+
import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
|
|
6
|
+
import { getTestEntries, getTaskNameWithPrefix, prettyTestPath, ROOT_SUITE_NAME, bgColor } from "./157.js";
|
|
7
|
+
import { logger_logger } from "./278.js";
|
|
6
8
|
const external_node_fs_ = __webpack_require__("node:fs");
|
|
7
|
-
const external_node_path_ = __webpack_require__("path");
|
|
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);
|
|
10
12
|
const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
13
|
+
const { getSetupFiles } = await import("./0~973.js").then((mod)=>({
|
|
14
|
+
getSetupFiles: mod.getSetupFiles
|
|
15
|
+
}));
|
|
11
16
|
const setupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
12
17
|
const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
|
|
13
18
|
return [
|
|
@@ -15,9 +20,18 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
15
20
|
getSetupFiles(setupFiles, rootPath)
|
|
16
21
|
];
|
|
17
22
|
}));
|
|
18
|
-
const
|
|
23
|
+
const globalSetupFiles = Object.fromEntries(context.projects.map((project)=>{
|
|
24
|
+
const { environmentName, rootPath, normalizedConfig: { globalSetup } } = project;
|
|
25
|
+
return [
|
|
26
|
+
environmentName,
|
|
27
|
+
getSetupFiles(globalSetup, rootPath)
|
|
28
|
+
];
|
|
29
|
+
}));
|
|
30
|
+
const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles);
|
|
19
31
|
const { getRsbuildStats, closeServer } = await createRsbuildServer({
|
|
20
32
|
globTestSourceEntries,
|
|
33
|
+
globalSetupFiles,
|
|
34
|
+
isWatchMode: false,
|
|
21
35
|
inspectedConfig: {
|
|
22
36
|
...context.normalizedConfig,
|
|
23
37
|
projects: context.projects.map((p)=>p.normalizedConfig)
|
|
@@ -31,9 +45,28 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
31
45
|
});
|
|
32
46
|
const updateSnapshot = context.snapshotManager.options.updateSnapshot;
|
|
33
47
|
const returns = await Promise.all(context.projects.map(async (project)=>{
|
|
34
|
-
const { entries, setupEntries, getSourceMaps, getAssetFiles, assetNames } = await getRsbuildStats({
|
|
48
|
+
const { entries, setupEntries, globalSetupEntries, getSourceMaps, getAssetFiles, assetNames } = await getRsbuildStats({
|
|
35
49
|
environmentName: project.environmentName
|
|
36
50
|
});
|
|
51
|
+
if (entries.length && globalSetupEntries.length && !project._globalSetups) {
|
|
52
|
+
project._globalSetups = true;
|
|
53
|
+
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
54
|
+
const assetFiles = await getAssetFiles(files);
|
|
55
|
+
const sourceMaps = await getSourceMaps(files);
|
|
56
|
+
const { success, errors } = await runGlobalSetup({
|
|
57
|
+
globalSetupEntries,
|
|
58
|
+
assetFiles,
|
|
59
|
+
sourceMaps,
|
|
60
|
+
interopDefault: true,
|
|
61
|
+
outputModule: project.outputModule
|
|
62
|
+
});
|
|
63
|
+
if (!success) return {
|
|
64
|
+
list: [],
|
|
65
|
+
errors,
|
|
66
|
+
assetNames,
|
|
67
|
+
getSourceMaps: ()=>null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
37
70
|
const list = await pool.collectTests({
|
|
38
71
|
entries,
|
|
39
72
|
setupEntries,
|
|
@@ -50,6 +83,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
50
83
|
}));
|
|
51
84
|
return {
|
|
52
85
|
list: returns.flatMap((r)=>r.list),
|
|
86
|
+
errors: returns.flatMap((r)=>r.errors || []),
|
|
53
87
|
getSourceMap: async (name)=>{
|
|
54
88
|
const resource = returns.find((r)=>r.assetNames.includes(name));
|
|
55
89
|
return (await resource?.getSourceMaps([
|
|
@@ -57,6 +91,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
|
|
|
57
91
|
]))?.[name];
|
|
58
92
|
},
|
|
59
93
|
close: async ()=>{
|
|
94
|
+
await runGlobalTeardown();
|
|
60
95
|
await closeServer();
|
|
61
96
|
await pool.close();
|
|
62
97
|
}
|
|
@@ -74,6 +109,7 @@ const collectTestFiles = async ({ context, globTestSourceEntries })=>{
|
|
|
74
109
|
}
|
|
75
110
|
return {
|
|
76
111
|
close: async ()=>{},
|
|
112
|
+
errors: [],
|
|
77
113
|
list,
|
|
78
114
|
getSourceMap: async (_name)=>null
|
|
79
115
|
};
|
|
@@ -95,7 +131,7 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
|
|
|
95
131
|
testEntries[name] = entries;
|
|
96
132
|
return entries;
|
|
97
133
|
};
|
|
98
|
-
const { list, close, getSourceMap } = filesOnly ? await collectTestFiles({
|
|
134
|
+
const { list, close, getSourceMap, errors = [] } = filesOnly ? await collectTestFiles({
|
|
99
135
|
context,
|
|
100
136
|
globTestSourceEntries
|
|
101
137
|
}) : await collectTests({
|
|
@@ -117,7 +153,7 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
|
|
|
117
153
|
});
|
|
118
154
|
if ('suite' === test.type) for (const child of test.tests)traverseTests(child);
|
|
119
155
|
};
|
|
120
|
-
const hasError = list.some((file)=>file.errors?.length);
|
|
156
|
+
const hasError = list.some((file)=>file.errors?.length) || errors.length;
|
|
121
157
|
const showProject = context.projects.length > 1;
|
|
122
158
|
if (hasError) {
|
|
123
159
|
const { printError } = await import("./131.js").then((mod)=>({
|
|
@@ -134,6 +170,18 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
|
|
|
134
170
|
}, rootPath);
|
|
135
171
|
}
|
|
136
172
|
}
|
|
173
|
+
if (errors.length) {
|
|
174
|
+
const { printError } = await import("./131.js").then((mod)=>({
|
|
175
|
+
printError: mod.error_printError
|
|
176
|
+
}));
|
|
177
|
+
for (const error of errors || []){
|
|
178
|
+
logger_logger.stderr(bgColor('bgRed', ' Unhandled Error '));
|
|
179
|
+
await printError(error, async (name)=>{
|
|
180
|
+
const sourceMap = await getSourceMap(name);
|
|
181
|
+
return sourceMap ? JSON.parse(sourceMap) : null;
|
|
182
|
+
}, rootPath);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
137
185
|
await close();
|
|
138
186
|
return list;
|
|
139
187
|
}
|
package/dist/0~809.js
CHANGED
package/dist/0~835.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import "./693.js";
|
|
5
|
+
import { createRequire as external_node_module_createRequire } from "./881.js";
|
|
6
|
+
import { pathToFileURL } from "./198.js";
|
|
6
7
|
import { node_vm, asModule, shouldInterop, interopModule } from "./0~346.js";
|
|
7
|
-
|
|
8
|
+
import { posix, logger_logger } from "./278.js";
|
|
9
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
8
10
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
9
11
|
const createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
10
12
|
const _require = (()=>{
|