@rstest/core 0.7.7 → 0.7.9

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/LICENSE.md +294 -0
  2. package/dist/0~130.js +2 -2
  3. package/dist/0~1472.js +48 -0
  4. package/dist/0~1981.js +3 -0
  5. package/dist/0~2173.js +25 -10
  6. package/dist/0~2255.js +2 -2
  7. package/dist/0~3062.js +0 -5
  8. package/dist/0~3919.js +1 -1
  9. package/dist/0~4403.js +6 -5
  10. package/dist/0~4809.js +4 -4
  11. package/dist/0~5835.js +2 -2
  12. package/dist/0~62.js +3 -3
  13. package/dist/0~6588.js +3 -3
  14. package/dist/0~6923.js +2 -2
  15. package/dist/0~7583.js +9 -8
  16. package/dist/0~7882.js +1144 -0
  17. package/dist/0~8426.js +1 -2
  18. package/dist/0~89.js +33 -24
  19. package/dist/0~9348.js +953 -0
  20. package/dist/0~9634.js +58 -10
  21. package/dist/1157.js +13 -118
  22. package/dist/{7913.js → 1294.js} +51 -1745
  23. package/dist/2672.js +647 -0
  24. package/dist/3278.js +3 -450
  25. package/dist/4484.js +38 -0
  26. package/dist/487.js +1739 -0
  27. package/dist/4899.js +11 -0
  28. package/dist/5734.js +1 -1
  29. package/dist/{0~6151.js → 6151.js} +169 -21
  30. package/dist/{0~6973.js → 6973.js} +5 -5
  31. package/dist/721.js +9 -0
  32. package/dist/9131.js +559 -502
  33. package/dist/browser-runtime/2~907.js +1211 -0
  34. package/dist/browser-runtime/2~907.js.map +1 -0
  35. package/dist/browser-runtime/389.js +22071 -0
  36. package/dist/browser-runtime/389.js.LICENSE.txt +329 -0
  37. package/dist/browser-runtime/389.js.map +1 -0
  38. package/dist/browser-runtime/index.d.ts +2806 -0
  39. package/dist/browser-runtime/index.js +1 -0
  40. package/dist/browser-runtime/rslib-runtime.js +50 -0
  41. package/dist/browser-runtime/rslib-runtime.js.map +1 -0
  42. package/dist/browser.d.ts +3329 -0
  43. package/dist/browser.js +14 -0
  44. package/dist/cssFilterLoader.mjs +1 -1
  45. package/dist/globalSetupWorker.js +3 -2
  46. package/dist/index.d.ts +67 -2
  47. package/dist/index.js +2 -1
  48. package/dist/rslib-runtime.js +27 -0
  49. package/dist/rstestSuppressWarnings.cjs +9 -0
  50. package/dist/worker.d.ts +66 -2
  51. package/dist/worker.js +415 -1
  52. package/package.json +29 -14
  53. package/dist/0~8957.js +0 -149
  54. package/dist/554.js +0 -417
  55. package/dist/5693.js +0 -91
  56. /package/dist/{7913.js.LICENSE.txt → 1294.js.LICENSE.txt} +0 -0
  57. /package/dist/{0~6151.js.LICENSE.txt → 6151.js.LICENSE.txt} +0 -0
package/dist/0~9634.js CHANGED
@@ -1,19 +1,24 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./5693.js";
4
+ import { getTaskNameWithPrefix, bgColor } from "./2672.js";
5
5
  import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
6
- import { getTestEntries, getTaskNameWithPrefix, prettyTestPath, ROOT_SUITE_NAME, bgColor } from "./1157.js";
7
- import { logger_logger } from "./3278.js";
8
- const external_node_fs_ = __webpack_require__("node:fs");
6
+ import { getTestEntries, prettyTestPath, ROOT_SUITE_NAME } from "./1157.js";
7
+ import { logger as logger_logger } from "./3278.js";
8
+ const external_node_fs_ = __webpack_require__("fs");
9
9
  const external_node_path_ = __webpack_require__("node:path");
10
10
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
11
11
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
12
- const collectTests = async ({ context, globTestSourceEntries })=>{
13
- const { getSetupFiles } = await import("./0~6973.js").then((mod)=>({
12
+ const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries })=>{
13
+ const { getSetupFiles } = await import("./6973.js").then((mod)=>({
14
14
  getSetupFiles: mod.getSetupFiles
15
15
  }));
16
- const setupFiles = Object.fromEntries(context.projects.map((project)=>{
16
+ if (0 === nodeProjects.length) return {
17
+ list: [],
18
+ getSourceMap: async (_name)=>null,
19
+ close: async ()=>{}
20
+ };
21
+ const setupFiles = Object.fromEntries(nodeProjects.map((project)=>{
17
22
  const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
18
23
  return [
19
24
  environmentName,
@@ -34,7 +39,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
34
39
  isWatchMode: false,
35
40
  inspectedConfig: {
36
41
  ...context.normalizedConfig,
37
- projects: context.projects.map((p)=>p.normalizedConfig)
42
+ projects: nodeProjects.map((p)=>p.normalizedConfig)
38
43
  },
39
44
  setupFiles,
40
45
  rsbuildInstance,
@@ -44,7 +49,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
44
49
  context
45
50
  });
46
51
  const updateSnapshot = context.snapshotManager.options.updateSnapshot;
47
- const returns = await Promise.all(context.projects.map(async (project)=>{
52
+ const returns = await Promise.all(nodeProjects.map(async (project)=>{
48
53
  const { entries, setupEntries, globalSetupEntries, getSourceMaps, getAssetFiles, assetNames } = await getRsbuildStats({
49
54
  environmentName: project.environmentName
50
55
  });
@@ -97,6 +102,20 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
97
102
  }
98
103
  };
99
104
  };
105
+ const collectBrowserTests = async ({ context, browserProjects })=>{
106
+ if (0 === browserProjects.length) return {
107
+ list: [],
108
+ close: async ()=>{}
109
+ };
110
+ const { loadBrowserModule } = await import("./0~1472.js").then((mod)=>({
111
+ loadBrowserModule: mod.loadBrowserModule
112
+ }));
113
+ const projectRoots = browserProjects.map((p)=>p.rootPath);
114
+ const { listBrowserTests } = await loadBrowserModule({
115
+ projectRoots
116
+ });
117
+ return listBrowserTests(context);
118
+ };
100
119
  const collectTestFiles = async ({ context, globTestSourceEntries })=>{
101
120
  const list = [];
102
121
  for (const project of context.projects){
@@ -114,6 +133,35 @@ const collectTestFiles = async ({ context, globTestSourceEntries })=>{
114
133
  getSourceMap: async (_name)=>null
115
134
  };
116
135
  };
136
+ const collectAllTests = async ({ context, globTestSourceEntries })=>{
137
+ const browserProjects = context.projects.filter((p)=>p.normalizedConfig.browser.enabled);
138
+ const nodeProjects = context.projects.filter((p)=>!p.normalizedConfig.browser.enabled);
139
+ const [nodeResult, browserResult] = await Promise.all([
140
+ collectNodeTests({
141
+ context,
142
+ nodeProjects,
143
+ globTestSourceEntries
144
+ }),
145
+ collectBrowserTests({
146
+ context,
147
+ browserProjects
148
+ })
149
+ ]);
150
+ return {
151
+ errors: nodeResult.errors,
152
+ list: [
153
+ ...nodeResult.list,
154
+ ...browserResult.list
155
+ ],
156
+ getSourceMap: nodeResult.getSourceMap,
157
+ close: async ()=>{
158
+ await Promise.all([
159
+ nodeResult.close(),
160
+ browserResult.close()
161
+ ]);
162
+ }
163
+ };
164
+ };
117
165
  async function listTests(context, { filesOnly, json, printLocation, includeSuites }) {
118
166
  const { rootPath } = context;
119
167
  const testEntries = {};
@@ -134,7 +182,7 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
134
182
  const { list, close, getSourceMap, errors = [] } = filesOnly ? await collectTestFiles({
135
183
  context,
136
184
  globTestSourceEntries
137
- }) : await collectTests({
185
+ }) : await collectAllTests({
138
186
  context,
139
187
  globTestSourceEntries
140
188
  });
package/dist/1157.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
+ import * as __rspack_external_node_fs_promises_153e37e0 from "node:fs/promises";
3
4
  import { __webpack_require__ } from "./rslib-runtime.js";
4
5
  import { fileURLToPath } from "url";
5
6
  import { createRequire } from "module";
6
- import promises, { lstat, readdir, realpath, stat as promises_stat, writeFile } from "node:fs/promises";
7
- import "./5693.js";
8
- import { normalize, isAbsolute, posix, join, parse } from "./3278.js";
7
+ import { castArray, parsePosix } from "./2672.js";
8
+ import { posix } from "./3278.js";
9
9
  __webpack_require__.add({
10
10
  "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
11
11
  const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js");
@@ -1412,121 +1412,13 @@ __webpack_require__.add({
1412
1412
  if ('' === last) return segs[segs.length - 2];
1413
1413
  return last;
1414
1414
  };
1415
+ },
1416
+ "node:fs/promises" (module) {
1417
+ module.exports = __rspack_external_node_fs_promises_153e37e0;
1415
1418
  }
1416
1419
  });
1417
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
1418
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
1419
- const formatRootStr = (rootStr, root)=>rootStr.replace('<rootDir>', normalize(root));
1420
- function getAbsolutePath(base, filepath) {
1421
- return isAbsolute(filepath) ? filepath : join(base, filepath);
1422
- }
1423
- const parsePosix = (filePath)=>{
1424
- const { dir, base } = parse(filePath);
1425
- return {
1426
- dir: dir.split("/").join('/'),
1427
- base
1428
- };
1429
- };
1430
- const isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj);
1431
- const castArray = (arr)=>{
1432
- if (void 0 === arr) return [];
1433
- return Array.isArray(arr) ? arr : [
1434
- arr
1435
- ];
1436
- };
1437
- const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype;
1438
- function formatError(error) {
1439
- if ('string' == typeof error || error instanceof Error) return error;
1440
- if (isPlainObject(error) && error.message) {
1441
- const e = new Error(error.name || 'unknown error');
1442
- e.message = error.message;
1443
- e.stack = error.stack;
1444
- return e;
1445
- }
1446
- return String(error);
1447
- }
1448
- const prettyTime = (milliseconds)=>{
1449
- if (milliseconds < 1000) return `${Math.round(milliseconds)}ms`;
1450
- const seconds = milliseconds / 1000;
1451
- const getSecond = (seconds, needDigits)=>{
1452
- if (!needDigits || seconds === Math.ceil(seconds)) return `${Math.round(seconds).toString()}s`;
1453
- const digits = seconds < 10 ? seconds >= 0.01 ? 2 : 3 : 1;
1454
- return `${seconds.toFixed(digits)}s`;
1455
- };
1456
- const minutes = Math.floor(seconds / 60);
1457
- const secondsRemainder = seconds % 60;
1458
- let time = '';
1459
- if (minutes > 0) time += `${minutes}m`;
1460
- if (secondsRemainder > 0) {
1461
- if (minutes > 0) time += ' ';
1462
- time += getSecond(secondsRemainder, !minutes);
1463
- }
1464
- return time;
1465
- };
1466
- const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
1467
- const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(` ${delimiter} `);
1468
- const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
1469
- const wrapRegex = (value)=>`${REGEXP_FLAG_PREFIX}${value.toString()}`;
1470
- const unwrapRegex = (value)=>{
1471
- if (value.startsWith(REGEXP_FLAG_PREFIX)) {
1472
- const regexStr = value.slice(REGEXP_FLAG_PREFIX.length);
1473
- const matches = regexStr.match(/^\/(.+)\/([gimuy]*)$/);
1474
- if (matches) {
1475
- const [, pattern, flags] = matches;
1476
- return new RegExp(pattern, flags);
1477
- }
1478
- }
1479
- return value;
1480
- };
1481
- const serializableConfig = (normalizedConfig)=>{
1482
- const { testNamePattern } = normalizedConfig;
1483
- return {
1484
- ...normalizedConfig,
1485
- testNamePattern: testNamePattern && 'string' != typeof testNamePattern ? wrapRegex(testNamePattern) : testNamePattern
1486
- };
1487
- };
1488
- const undoSerializableConfig = (normalizedConfig)=>{
1489
- const { testNamePattern } = normalizedConfig;
1490
- return {
1491
- ...normalizedConfig,
1492
- testNamePattern: testNamePattern && 'string' == typeof testNamePattern ? unwrapRegex(testNamePattern) : testNamePattern
1493
- };
1494
- };
1495
- const getNodeVersion = ()=>{
1496
- if ('string' == typeof process.versions?.node) {
1497
- const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
1498
- return {
1499
- major,
1500
- minor,
1501
- patch
1502
- };
1503
- }
1504
- return {
1505
- major: 0,
1506
- minor: 0,
1507
- patch: 0
1508
- };
1509
- };
1510
- const needFlagExperimentalDetectModule = ()=>{
1511
- const { major, minor } = getNodeVersion();
1512
- if (20 === major && minor >= 10) return true;
1513
- if (22 === major && minor < 7) return true;
1514
- return false;
1515
- };
1516
- const ADDITIONAL_NODE_BUILTINS = [
1517
- /^node:/,
1518
- 'pnpapi'
1519
- ];
1520
- const bgColor = (background, str)=>{
1521
- if ([
1522
- 'bgRed',
1523
- 'bgBlack'
1524
- ].includes(background)) return picocolors_default()[background](picocolors_default().white(picocolors_default().bold(str)));
1525
- return picocolors_default()[background](picocolors_default().blackBright(picocolors_default().bold(str)));
1526
- };
1527
- const isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
1528
1420
  const external_node_path_ = __webpack_require__("node:path");
1529
- const external_node_fs_ = __webpack_require__("node:fs");
1421
+ const external_node_fs_ = __webpack_require__("fs");
1530
1422
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
1531
1423
  function cleanPath(path) {
1532
1424
  let normalized = (0, external_node_path_.normalize)(path);
@@ -2012,6 +1904,7 @@ var Builder = class {
2012
1904
  return this;
2013
1905
  }
2014
1906
  };
1907
+ const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
2015
1908
  const isReadonlyArray = Array.isArray;
2016
1909
  const isWin = "win32" === process.platform;
2017
1910
  const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
@@ -2317,6 +2210,9 @@ const globalApis = [
2317
2210
  'onTestFailed'
2318
2211
  ];
2319
2212
  const TS_CONFIG_FILE = 'tsconfig.json';
2213
+ const promises_ = __webpack_require__("node:fs/promises");
2214
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
2215
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
2320
2216
  const filterFiles = (testFiles, filters, dir)=>{
2321
2217
  if (!filters.length) return testFiles;
2322
2218
  const fileFilters = 'win32' === process.platform ? filters.map((f)=>f.split(posix.sep).join('/')) : filters;
@@ -2360,7 +2256,7 @@ const getTestEntries = async ({ include, exclude, rootPath, projectRoot, fileFil
2360
2256
  });
2361
2257
  await Promise.all(sourceFiles.map(async (file)=>{
2362
2258
  try {
2363
- const code = await promises.readFile(file, 'utf-8');
2259
+ const code = await promises_["default"].readFile(file, 'utf-8');
2364
2260
  if (hasInSourceTestCode(code)) testFiles.push(file);
2365
2261
  } catch {
2366
2262
  return;
@@ -2384,5 +2280,4 @@ const formatTestPath = (root, testFilePath)=>{
2384
2280
  if (posix.isAbsolute(testPath) && testPath.includes(root)) testPath = posix.relative(root, testPath);
2385
2281
  return prettyTestPath(testPath);
2386
2282
  };
2387
- const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
2388
- export { ADDITIONAL_NODE_BUILTINS, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, ROOT_SUITE_NAME, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, TS_CONFIG_FILE, bgColor, castArray, filterProjects, formatError, formatRootStr, formatTestEntryName, formatTestPath, getAbsolutePath, getTaskNameWithPrefix, getTestEntries, glob, globalApis, isDynamicPattern, isObject, isTTY, lstat, needFlagExperimentalDetectModule, prettyTestPath, prettyTime, promises_stat, readdir, realpath, serializableConfig, undoSerializableConfig, writeFile };
2283
+ export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, ROOT_SUITE_NAME, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, TS_CONFIG_FILE, filterProjects, formatTestEntryName, formatTestPath, getTestEntries, glob, globalApis, isDynamicPattern, prettyTestPath };