@rstest/core 0.8.1 → 0.8.3

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.
Files changed (57) hide show
  1. package/dist/0~130.js +1 -2
  2. package/dist/0~1472.js +2 -3
  3. package/dist/0~1981.js +1 -2
  4. package/dist/0~2173.js +65 -27
  5. package/dist/0~2255.js +1 -2
  6. package/dist/0~3062.js +1 -2
  7. package/dist/0~3346.js +1 -2
  8. package/dist/0~3919.js +1 -2
  9. package/dist/0~4403.js +4 -4
  10. package/dist/0~4809.js +1 -2
  11. package/dist/0~5835.js +1 -2
  12. package/dist/0~62.js +1 -2
  13. package/dist/0~6588.js +4 -4
  14. package/dist/0~6907.js +1 -2
  15. package/dist/0~6923.js +1 -2
  16. package/dist/0~7583.js +1 -2
  17. package/dist/0~7882.js +7 -579
  18. package/dist/0~8426.js +1 -2
  19. package/dist/0~89.js +16 -12
  20. package/dist/0~9348.js +1 -2
  21. package/dist/0~9634.js +21 -8
  22. package/dist/1157.js +48 -97
  23. package/dist/1294.js +1 -2
  24. package/dist/1672.js +1 -2
  25. package/dist/3160.js +111 -8
  26. package/dist/3216.js +1 -2
  27. package/dist/4397.js +1 -2
  28. package/dist/4484.js +1 -2
  29. package/dist/487.js +1 -2
  30. package/dist/4881.js +1 -2
  31. package/dist/4899.js +2 -2
  32. package/dist/5734.js +1 -2
  33. package/dist/6151.js +13 -10
  34. package/dist/6198.js +1 -2
  35. package/dist/6973.js +1 -2
  36. package/dist/7011.js +1 -2
  37. package/dist/721.js +1 -2
  38. package/dist/9131.js +1329 -27
  39. package/dist/browser-runtime/2~907.js +0 -2
  40. package/dist/browser-runtime/389.js +14 -11
  41. package/dist/browser-runtime/389.js.LICENSE.txt +22 -0
  42. package/dist/browser-runtime/index.d.ts +100 -111
  43. package/dist/browser-runtime/rslib-runtime.js +0 -2
  44. package/dist/browser.d.ts +156 -110
  45. package/dist/browser.js +2 -2
  46. package/dist/globalSetupWorker.js +1 -2
  47. package/dist/index.d.ts +100 -110
  48. package/dist/index.js +1 -2
  49. package/dist/mockRuntimeCode.js +63 -174
  50. package/dist/rslib-runtime.js +1 -2
  51. package/dist/worker.d.ts +99 -110
  52. package/dist/worker.js +1 -2
  53. package/package.json +4 -4
  54. package/dist/browser-runtime/2~907.js.map +0 -1
  55. package/dist/browser-runtime/389.js.map +0 -1
  56. package/dist/browser-runtime/rslib-runtime.js.map +0 -1
  57. /package/dist/{1157.js.LICENSE.txt → 3160.js.LICENSE.txt} +0 -0
package/dist/0~130.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { __webpack_require__ } from "./rslib-runtime.js";
4
3
  import { AssertionError, strict } from "node:assert";
5
4
  import { Console } from "node:console";
package/dist/0~1472.js CHANGED
@@ -1,11 +1,10 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { createRequire } from "./4881.js";
4
3
  import { pathToFileURL } from "./6198.js";
5
4
  import "./1157.js";
6
5
  import { logger as logger_logger, color } from "./3160.js";
7
6
  async function loadBrowserModule(options = {}) {
8
- const coreVersion = "0.8.1";
7
+ const coreVersion = "0.8.3";
9
8
  const { projectRoots = [] } = options;
10
9
  let browserModule;
11
10
  let browserVersion;
package/dist/0~1981.js CHANGED
@@ -1,3 +1,2 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  export { Readable, Writable } from "node:stream";
package/dist/0~2173.js CHANGED
@@ -1,6 +1,5 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { getTestEntries } from "./1157.js";
1
+ import "node:module";
2
+ import { resolveShardedEntries, getTestEntries } from "./1157.js";
4
3
  import { createCoverageProvider } from "./5734.js";
5
4
  import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
6
5
  import { loadBrowserModule } from "./0~1472.js";
@@ -156,26 +155,35 @@ async function runBrowserModeTests(context, browserProjects, options) {
156
155
  async function runTests(context) {
157
156
  const browserProjects = context.projects.filter((project)=>project.normalizedConfig.browser.enabled);
158
157
  const nodeProjects = context.projects.filter((project)=>!project.normalizedConfig.browser.enabled);
159
- const hasBrowserTests = context.normalizedConfig.browser.enabled || browserProjects.length > 0;
160
- const hasNodeTests = nodeProjects.length > 0;
158
+ const hasBrowserProjects = browserProjects.length > 0;
159
+ const hasNodeProjects = nodeProjects.length > 0;
161
160
  const isWatchMode = 'watch' === context.command;
162
- const shouldUnifyReporter = !isWatchMode && hasBrowserTests && hasNodeTests;
163
- if (hasBrowserTests && !hasNodeTests) return void await runBrowserModeTests(context, browserProjects, {
164
- skipOnTestRunEnd: false
165
- });
166
- let browserResultPromise;
167
- if (hasBrowserTests) browserResultPromise = runBrowserModeTests(context, browserProjects, {
168
- skipOnTestRunEnd: shouldUnifyReporter
169
- });
170
- if (!hasNodeTests) {
171
- if (browserResultPromise) await browserResultPromise;
161
+ const shouldUnifyReporter = !isWatchMode && hasBrowserProjects && hasNodeProjects;
162
+ if (hasBrowserProjects && !hasNodeProjects) {
163
+ const { coverage } = context.normalizedConfig;
164
+ if (coverage.enabled) logger_logger.log(` ${color.gray('Coverage enabled with')} %s\n`, color.yellow(coverage.provider));
165
+ const browserResult = await runBrowserModeTests(context, browserProjects, {
166
+ skipOnTestRunEnd: false
167
+ });
168
+ if (coverage.enabled && browserResult?.results) {
169
+ const coverageProvider = await createCoverageProvider(coverage, context.rootPath);
170
+ if (coverageProvider) {
171
+ const { generateCoverage } = await import("./0~4403.js").then((mod)=>({
172
+ generateCoverage: mod.generateCoverage
173
+ }));
174
+ await generateCoverage(context, browserResult.results, coverageProvider);
175
+ }
176
+ }
172
177
  return;
173
178
  }
174
- const projects = nodeProjects;
175
- const { rootPath, reporters, snapshotManager, command, normalizedConfig: { coverage } } = context;
176
- const entriesCache = new Map();
179
+ let browserResultPromise;
180
+ const allProjects = context.projects;
181
+ const { rootPath, reporters, snapshotManager, command, normalizedConfig } = context;
182
+ const { coverage, shard } = normalizedConfig;
183
+ const entriesCache = await resolveShardedEntries(context) || new Map();
177
184
  const globTestSourceEntries = async (name)=>{
178
- const { include, exclude, includeSource, root } = projects.find((p)=>p.environmentName === name).normalizedConfig;
185
+ if (!isWatchMode && shard && entriesCache.has(name)) return entriesCache.get(name).entries;
186
+ const { include, exclude, includeSource, root } = allProjects.find((p)=>p.environmentName === name).normalizedConfig;
179
187
  const entries = await getTestEntries({
180
188
  include,
181
189
  exclude: exclude.patterns,
@@ -190,6 +198,28 @@ async function runTests(context) {
190
198
  });
191
199
  return entries;
192
200
  };
201
+ let browserProjectsToRun = browserProjects;
202
+ let nodeProjectsToRun = nodeProjects;
203
+ if (shard) {
204
+ browserProjectsToRun = browserProjects.filter((p)=>Object.keys(entriesCache.get(p.environmentName)?.entries || {}).length > 0);
205
+ nodeProjectsToRun = nodeProjects.filter((p)=>Object.keys(entriesCache.get(p.environmentName)?.entries || {}).length > 0);
206
+ }
207
+ const hasBrowserTestsToRun = browserProjectsToRun.length > 0;
208
+ const hasNodeTestsToRun = nodeProjectsToRun.length > 0;
209
+ if (hasBrowserTestsToRun) {
210
+ const browserEntries = new Map();
211
+ if (shard) for (const p of browserProjectsToRun)browserEntries.set(p.environmentName, entriesCache.get(p.environmentName));
212
+ browserResultPromise = runBrowserModeTests(context, browserProjectsToRun, {
213
+ skipOnTestRunEnd: shouldUnifyReporter,
214
+ shardedEntries: shard ? browserEntries : void 0
215
+ });
216
+ }
217
+ if (!hasNodeTestsToRun) {
218
+ if (browserResultPromise) await browserResultPromise;
219
+ if (hasBrowserTestsToRun) return;
220
+ if (!hasNodeProjects) return;
221
+ }
222
+ const projects = nodeProjectsToRun;
193
223
  const { getSetupFiles } = await import("./6973.js").then((mod)=>({
194
224
  getSetupFiles: mod.getSetupFiles
195
225
  }));
@@ -214,17 +244,21 @@ async function runTests(context) {
214
244
  projects: projects.map((p)=>p.normalizedConfig)
215
245
  },
216
246
  isWatchMode,
217
- globTestSourceEntries: isWatchMode ? globTestSourceEntries : async (name)=>{
218
- if (entriesCache.has(name)) return entriesCache.get(name).entries;
219
- return globTestSourceEntries(name);
220
- },
247
+ globTestSourceEntries,
221
248
  setupFiles,
222
249
  globalSetupFiles,
223
250
  rsbuildInstance,
224
251
  rootPath
225
252
  });
226
253
  const entryFiles = Array.from(entriesCache.values()).reduce((acc, entry)=>acc.concat(Object.values(entry.entries) || []), []);
227
- const recommendWorkerCount = 'watch' === command ? 1 / 0 : entryFiles.length;
254
+ const getRecommendWorkerCount = ()=>{
255
+ const nodeEntries = Array.from(entriesCache.entries()).filter(([key])=>{
256
+ const project = projects.find((p)=>p.environmentName === key);
257
+ return project?.normalizedConfig.browser.enabled !== true;
258
+ });
259
+ return nodeEntries.flatMap(([_key, entry])=>Object.values(entry.entries) || []).length;
260
+ };
261
+ const recommendWorkerCount = 'watch' === command ? 1 / 0 : getRecommendWorkerCount();
228
262
  const pool = await createPool({
229
263
  context,
230
264
  recommendWorkerCount
@@ -302,6 +336,8 @@ async function runTests(context) {
302
336
  const results = returns.flatMap((r)=>r.results);
303
337
  const testResults = returns.flatMap((r)=>r.testResults);
304
338
  const errors = returns.flatMap((r)=>r.errors || []);
339
+ if (shouldUnifyReporter && browserResult?.results) results.push(...browserResult.results);
340
+ if (shouldUnifyReporter && browserResult?.testResults) testResults.push(...browserResult.testResults);
305
341
  context.updateReporterResultState(results, testResults, currentDeletedEntries);
306
342
  const nodeHasFailure = results.some((r)=>'fail' === r.status) || errors.length;
307
343
  const browserHasFailure = shouldUnifyReporter && browserResult?.hasFailure;
@@ -310,13 +346,15 @@ async function runTests(context) {
310
346
  else logger_logger.log(color.yellow('No test files found.'));
311
347
  else {
312
348
  const code = context.normalizedConfig.passWithNoTests ? 0 : 1;
313
- logger_logger.log(color[code ? 'red' : 'yellow'](`No test files found, exiting with code ${code}.`));
349
+ const message = `No test files found, exiting with code ${code}.`;
350
+ if (0 === code) logger_logger.log(color.yellow(message));
351
+ else logger_logger.error(color.red(message));
314
352
  process.exitCode = code;
315
353
  }
316
354
  if ('all' === mode) {
317
355
  if (context.fileFilters?.length) logger_logger.log(color.gray('filter: '), context.fileFilters.join(color.gray(', ')));
318
- projects.forEach((p)=>{
319
- if (projects.length > 1) {
356
+ allProjects.forEach((p)=>{
357
+ if (allProjects.length > 1) {
320
358
  logger_logger.log('');
321
359
  logger_logger.log(color.gray('project:'), p.name);
322
360
  }
package/dist/0~2255.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { __webpack_require__ } from "./rslib-runtime.js";
4
3
  import "./3160.js";
5
4
  const external_node_fs_ = __webpack_require__("node:fs");
package/dist/0~3062.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  const LIVING_KEYS = [
4
3
  'DOMException',
5
4
  'EventTarget',
package/dist/0~3346.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  const shouldInterop = ({ interopDefault = true, modulePath, mod })=>{
4
3
  if (!interopDefault) return false;
5
4
  return !modulePath.endsWith('.mjs') && 'default' in mod;
package/dist/0~3919.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { __webpack_require__ } from "./rslib-runtime.js";
4
3
  import "./3160.js";
5
4
  __webpack_require__.add({
package/dist/0~4403.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { isDynamicPattern, glob } from "./1157.js";
4
3
  import { normalize, logger as logger_logger } from "./3160.js";
5
4
  const getIncludedFiles = async (coverage, rootPath, fs)=>{
@@ -53,12 +52,13 @@ async function generateCoverage(context, results, coverageProvider) {
53
52
  });
54
53
  if (!thresholdResult.success) {
55
54
  logger_logger.log('');
56
- logger_logger.log(thresholdResult.message);
55
+ logger_logger.stderr(thresholdResult.message);
57
56
  process.exitCode = 1;
58
57
  }
59
58
  }
60
59
  } catch (error) {
61
- logger_logger.error('Failed to generate coverage reports:', error);
60
+ logger_logger.stderr('Failed to generate coverage reports:', error);
61
+ process.exitCode = 1;
62
62
  }
63
63
  }
64
64
  async function generateCoverageForUntestedFiles(environmentName, uncoveredFiles, coverageMap, coverageProvider) {
package/dist/0~4809.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { checkPkgInstalled } from "./1294.js";
4
3
  import { installGlobal, addDefaultErrorHandler } from "./0~3062.js";
5
4
  const environment = {
package/dist/0~5835.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { __webpack_require__ } from "./rslib-runtime.js";
4
3
  import { logger as logger_logger } from "./3160.js";
5
4
  import { createRequire as external_node_module_createRequire } from "./4881.js";
package/dist/0~62.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { checkPkgInstalled } from "./1294.js";
4
3
  import { installGlobal, addDefaultErrorHandler } from "./0~3062.js";
5
4
  const environment = {
package/dist/0~6588.js CHANGED
@@ -1,7 +1,6 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import { logger as logger_logger, color, isTTY, ansiEnabled } from "./3160.js";
3
+ import { color, logger as logger_logger, isTTY } from "./3160.js";
5
4
  import { runRest } from "./9131.js";
6
5
  import "./1157.js";
7
6
  const GLOB_REGEX = /[*?{}[\]()!@+|]/;
@@ -29,12 +28,13 @@ async function createChokidar(pathOrGlobs, root, options) {
29
28
  return chokidar.watch(Array.from(watchFiles), options);
30
29
  }
31
30
  const external_node_path_ = __webpack_require__("node:path");
31
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
32
32
  let cleaners = [];
33
33
  const onBeforeRestart = (cleaner)=>{
34
34
  cleaners.push(cleaner);
35
35
  };
36
36
  const clearConsole = ()=>{
37
- if (isTTY() && !process.env.DEBUG && ansiEnabled) process.stdout.write('\x1B[H\x1B[2J');
37
+ if (isTTY() && !process.env.DEBUG && picocolors.isColorSupported) process.stdout.write('\x1B[H\x1B[2J');
38
38
  };
39
39
  const beforeRestart = async ({ filePath, root, clear = true })=>{
40
40
  if (clear) clearConsole();
package/dist/0~6907.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { encode } from "./4397.js";
4
3
  class BitSet {
5
4
  constructor(arg){
package/dist/0~6923.js CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import { __webpack_require__ } from "./rslib-runtime.js";
4
3
  import { logger as logger_logger } from "./3160.js";
5
4
  import { pathToFileURL } from "./6198.js";
package/dist/0~7583.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /*! For license information please see 0~7583.js.LICENSE.txt */
2
- import 'module';
3
- /*#__PURE__*/ import.meta.url;
2
+ import "node:module";
4
3
  import { __webpack_require__ } from "./rslib-runtime.js";
5
4
  import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "fs/promises";
6
5
  import "./3160.js";