@rstest/core 0.7.4 → 0.7.6

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 (43) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/0~130.js +2 -2
  3. package/dist/{0~173.js → 0~2173.js} +15 -8
  4. package/dist/{0~255.js → 0~2255.js} +1 -1
  5. package/dist/{0~346.js → 0~3346.js} +2 -2
  6. package/dist/{0~919.js → 0~3919.js} +1 -1
  7. package/dist/{0~403.js → 0~4403.js} +3 -3
  8. package/dist/{0~809.js → 0~4809.js} +2 -2
  9. package/dist/{0~835.js → 0~5835.js} +12 -7
  10. package/dist/{0~151.js → 0~6151.js} +163 -292
  11. package/dist/0~62.js +2 -2
  12. package/dist/{0~588.js → 0~6588.js} +6 -6
  13. package/dist/{0~907.js → 0~6907.js} +2 -2
  14. package/dist/{0~923.js → 0~6923.js} +11 -7
  15. package/dist/0~6973.js +50 -0
  16. package/dist/{0~583.js → 0~7583.js} +4 -4
  17. package/dist/{0~426.js → 0~8426.js} +3 -3
  18. package/dist/0~89.js +81 -40
  19. package/dist/0~8957.js +149 -0
  20. package/dist/{0~634.js → 0~9634.js} +9 -5
  21. package/dist/{157.js → 1157.js} +5 -42
  22. package/dist/{216.js → 3216.js} +2 -2
  23. package/dist/{278.js → 3278.js} +2 -2
  24. package/dist/{397.js → 4397.js} +1 -1
  25. package/dist/4881.js +3 -0
  26. package/dist/554.js +26 -21
  27. package/dist/{664.js → 5693.js} +0 -2
  28. package/dist/{734.js → 5734.js} +4 -3
  29. package/dist/6198.js +3 -0
  30. package/dist/{913.js → 7913.js} +7 -6
  31. package/dist/{131.js → 9131.js} +31 -20
  32. package/dist/globalSetupWorker.js +8 -6
  33. package/dist/index.d.ts +21 -1
  34. package/dist/index.js +1 -1
  35. package/dist/rslib-runtime.js +1 -1
  36. package/dist/worker.d.ts +21 -1
  37. package/package.json +5 -5
  38. package/dist/198.js +0 -4
  39. /package/dist/{0~681.js → 0~3062.js} +0 -0
  40. /package/dist/{0~151.js.LICENSE.txt → 0~6151.js.LICENSE.txt} +0 -0
  41. /package/dist/{0~583.js.LICENSE.txt → 0~7583.js.LICENSE.txt} +0 -0
  42. /package/dist/{672.js → 1672.js} +0 -0
  43. /package/dist/{913.js.LICENSE.txt → 7913.js.LICENSE.txt} +0 -0
package/dist/0~62.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { checkPkgInstalled } from "./913.js";
4
- import { installGlobal, addDefaultErrorHandler } from "./0~681.js";
3
+ import { checkPkgInstalled } from "./7913.js";
4
+ import { installGlobal, addDefaultErrorHandler } from "./0~3062.js";
5
5
  const environment = {
6
6
  name: 'jsdom',
7
7
  async setup (global, { jsdom = {} }) {
@@ -1,14 +1,14 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./664.js";
5
- import { runRest } from "./131.js";
6
- import { isTTY } from "./157.js";
7
- import { logger_logger } from "./278.js";
4
+ import "./5693.js";
5
+ import { runRest } from "./9131.js";
6
+ import { isTTY } from "./1157.js";
7
+ import { logger_logger } from "./3278.js";
8
8
  const GLOB_REGEX = /[*?{}[\]()!@+|]/;
9
9
  const isGlob = (str)=>GLOB_REGEX.test(str);
10
10
  async function createChokidar(pathOrGlobs, root, options) {
11
- const chokidar = await import("./0~583.js").then((mod)=>({
11
+ const chokidar = await import("./0~7583.js").then((mod)=>({
12
12
  watch: mod.watch
13
13
  }));
14
14
  const watchFiles = new Set();
@@ -18,7 +18,7 @@ async function createChokidar(pathOrGlobs, root, options) {
18
18
  return false;
19
19
  });
20
20
  if (globPatterns.length) {
21
- const { glob } = await import("./157.js").then((mod)=>({
21
+ const { glob } = await import("./1157.js").then((mod)=>({
22
22
  glob: mod.glob
23
23
  }));
24
24
  const files = await glob(globPatterns, {
@@ -1,6 +1,6 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { encode } from "./397.js";
3
+ import { encode } from "./4397.js";
4
4
  class BitSet {
5
5
  constructor(arg){
6
6
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -137,7 +137,7 @@ class Chunk {
137
137
  }
138
138
  }
139
139
  function getBtoa() {
140
- if ('undefined' != typeof globalThis && 'function' == typeof globalThis.btoa) return (str)=>globalThis.btoa(unescape(encodeURIComponent(str)));
140
+ if ("u" > typeof globalThis && 'function' == typeof globalThis.btoa) return (str)=>globalThis.btoa(unescape(encodeURIComponent(str)));
141
141
  if ('function' == typeof Buffer) return (str)=>Buffer.from(str, 'utf-8').toString('base64');
142
142
  return ()=>{
143
143
  throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
@@ -1,10 +1,10 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./664.js";
5
- import { pathToFileURL } from "./198.js";
6
- import { node_vm, interopModule, shouldInterop } from "./0~346.js";
7
- import { posix, logger_logger } from "./278.js";
4
+ import "./5693.js";
5
+ import { pathToFileURL } from "./6198.js";
6
+ import { node_vm, interopModule, shouldInterop } from "./0~3346.js";
7
+ import { posix, logger_logger } from "./3278.js";
8
8
  const external_node_path_ = __webpack_require__("node:path");
9
9
  var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
10
10
  EsmMode[EsmMode["Unknown"] = 0] = "Unknown";
@@ -13,10 +13,14 @@ var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
13
13
  return EsmMode;
14
14
  }({});
15
15
  const isRelativePath = (p)=>/^\.\.?\//.test(p);
16
+ let latestAssetFiles = {};
17
+ const updateLatestAssetFiles = (assetFiles)=>{
18
+ latestAssetFiles = assetFiles;
19
+ };
16
20
  const defineRstestDynamicImport = ({ distPath, testPath, assetFiles, interopDefault, returnModule, esmMode })=>async (specifier, importAttributes)=>{
17
21
  const currentDirectory = posix.dirname(distPath);
18
22
  const joinedPath = isRelativePath(specifier) ? posix.join(currentDirectory, specifier) : specifier;
19
- const content = assetFiles[joinedPath];
23
+ const content = assetFiles[joinedPath] || latestAssetFiles[joinedPath];
20
24
  if (content) try {
21
25
  return await loadModule({
22
26
  codeContent: content,
@@ -114,7 +118,7 @@ const loadModule = async ({ codeContent, distPath, testPath, assetFiles, interop
114
118
  });
115
119
  meta.readWasmFile = (wasmPath, callback)=>{
116
120
  const joinedPath = isRelativePath(wasmPath.pathname) ? posix.join(posix.dirname(distPath), wasmPath.pathname) : wasmPath.pathname;
117
- const content = assetFiles[posix.normalize(joinedPath)];
121
+ const content = assetFiles[posix.normalize(joinedPath)] || latestAssetFiles[posix.normalize(joinedPath)];
118
122
  if (content) callback(null, Buffer.from(content, 'base64'));
119
123
  else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
120
124
  };
@@ -147,4 +151,4 @@ const loadModule = async ({ codeContent, distPath, testPath, assetFiles, interop
147
151
  const ns = esm.namespace;
148
152
  return ns.default && ns.default instanceof Promise ? ns.default : ns;
149
153
  };
150
- export { asModule, loadEsModule_EsmMode, loadModule };
154
+ export { asModule, loadEsModule_EsmMode, loadModule, updateLatestAssetFiles };
package/dist/0~6973.js ADDED
@@ -0,0 +1,50 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import { __webpack_require__ } from "./rslib-runtime.js";
4
+ import "./5693.js";
5
+ import { fileURLToPath } from "./6198.js";
6
+ import { rspack } from "./9131.js";
7
+ import { getAbsolutePath, formatTestEntryName } from "./1157.js";
8
+ import { posix } from "./3278.js";
9
+ const external_node_fs_ = __webpack_require__("fs");
10
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
11
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
12
+ const tryResolve = (request, rootPath)=>{
13
+ const { resolver } = rspack.experiments;
14
+ const esmFirstResolver = new resolver.ResolverFactory({
15
+ conditionNames: [
16
+ 'node',
17
+ 'import',
18
+ 'require'
19
+ ]
20
+ });
21
+ const { path: resolvedPath } = esmFirstResolver.sync(rootPath, request);
22
+ return resolvedPath;
23
+ };
24
+ const getSetupFiles = (setups, rootPath)=>{
25
+ if (!setups.length) return {};
26
+ return Object.fromEntries(setups.map((filePath)=>{
27
+ const setupFile = filePath.startsWith('file://') ? fileURLToPath(filePath) : filePath;
28
+ const setupFilePath = getAbsolutePath(rootPath, setupFile);
29
+ try {
30
+ if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
31
+ let errorMessage = `Setup file ${picocolors_default().red(setupFile)} not found`;
32
+ if (setupFilePath !== setupFile) errorMessage += picocolors_default().gray(` (resolved path: ${setupFilePath})`);
33
+ throw errorMessage;
34
+ }
35
+ const relativePath = posix.relative(rootPath, setupFilePath);
36
+ return [
37
+ formatTestEntryName(relativePath),
38
+ setupFilePath
39
+ ];
40
+ } catch (err) {
41
+ const resolvedPath = tryResolve(setupFile, rootPath);
42
+ if (resolvedPath) return [
43
+ formatTestEntryName(setupFile),
44
+ resolvedPath
45
+ ];
46
+ throw err;
47
+ }
48
+ }));
49
+ };
50
+ export { getSetupFiles };
@@ -1,12 +1,12 @@
1
- /*! For license information please see 0~583.js.LICENSE.txt */
1
+ /*! For license information please see 0~7583.js.LICENSE.txt */
2
2
  import 'module';
3
3
  /*#__PURE__*/ import.meta.url;
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 "./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";
9
- import { EventEmitter } from "./131.js";
7
+ import "./5693.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 "./1157.js";
9
+ import { EventEmitter } from "./9131.js";
10
10
  const external_node_path_ = __webpack_require__("node:path");
11
11
  const EntryTypes = {
12
12
  FILE_TYPE: 'files',
@@ -1,9 +1,9 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./157.js";
5
- import "./664.js";
6
- import { relative } from "./278.js";
4
+ import "./1157.js";
5
+ import "./5693.js";
6
+ import { relative } from "./3278.js";
7
7
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
8
8
  var picomatch_default = /*#__PURE__*/ __webpack_require__.n(picomatch);
9
9
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
package/dist/0~89.js CHANGED
@@ -4,12 +4,13 @@ import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import node_events from "node:events";
5
5
  import { Tinypool } from "tinypool";
6
6
  import node_inspector from "node:inspector";
7
- import { isBuiltin } from "./664.js";
8
- import { node_process, basename, isDebug, dirname, posix, resolve as pathe_M_eThtNZ_resolve, join } from "./278.js";
9
- import { fileURLToPath } from "./198.js";
10
- import { node_v8, createBirpc } from "./216.js";
11
- import { serializableConfig, bgColor, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, castArray, ADDITIONAL_NODE_BUILTINS, needFlagExperimentalDetectModule } from "./157.js";
12
- import { core_logger, createRsbuild } from "./131.js";
7
+ import "./5693.js";
8
+ import { node_process, basename, isDebug, dirname, posix, resolve as pathe_M_eThtNZ_resolve, join } from "./3278.js";
9
+ import { fileURLToPath } from "./6198.js";
10
+ import { node_v8, createBirpc } from "./3216.js";
11
+ import { serializableConfig, bgColor, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, castArray, ADDITIONAL_NODE_BUILTINS, needFlagExperimentalDetectModule } from "./1157.js";
12
+ import { isBuiltin } from "./4881.js";
13
+ import { core_logger, createRsbuild } from "./9131.js";
13
14
  const DefaultMaxHeapSize = 1073741824;
14
15
  function memory_isMemorySufficient(options) {
15
16
  const { memoryThreshold = 0.7, maxHeapSize = DefaultMaxHeapSize } = options || {};
@@ -561,6 +562,7 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, globalSe
561
562
  };
562
563
  };
563
564
  config.watchOptions ??= {};
565
+ config.watchOptions.aggregateTimeout = 5;
564
566
  config.watchOptions.ignored = castArray(config.watchOptions.ignored || []);
565
567
  if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
566
568
  config.watchOptions.ignored.push(TEMP_RSTEST_OUTPUT_DIR_GLOB, context.normalizedConfig.coverage.reportsDirectory, ...Object.values(globalSetupFiles?.[environment.name] || {}), '**/*.snap');
@@ -752,7 +754,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
752
754
  const pluginCacheControl = (setupFiles)=>({
753
755
  name: 'rstest:cache-control',
754
756
  setup: (api)=>{
755
- api.transform({
757
+ if (setupFiles.length) api.transform({
756
758
  test: setupFiles
757
759
  }, ({ code })=>({
758
760
  code: `
@@ -834,10 +836,10 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles, global
834
836
  }
835
837
  });
836
838
  if (coverage?.enabled && 'list' !== command) {
837
- const { loadCoverageProvider } = await import("./734.js").then((mod)=>({
839
+ const { loadCoverageProvider } = await import("./5734.js").then((mod)=>({
838
840
  loadCoverageProvider: mod.loadCoverageProvider
839
841
  }));
840
- const { pluginCoverageCore } = await import("./0~255.js").then((mod)=>({
842
+ const { pluginCoverageCore } = await import("./0~2255.js").then((mod)=>({
841
843
  pluginCoverageCore: mod.pluginCoverageCore
842
844
  }));
843
845
  const { pluginCoverage } = await loadCoverageProvider(coverage, context.rootPath);
@@ -849,50 +851,79 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles, global
849
851
  }
850
852
  return rsbuildInstance;
851
853
  };
852
- const calcEntriesToRerun = (entries, chunks, buildData, runtimeChunkName)=>{
853
- const entryToChunkHashesMap = new Map();
854
- const buildChunkHashes = (entry)=>{
854
+ const calcEntriesToRerun = (entries, chunks, buildData, runtimeChunkName, setupEntries)=>{
855
+ const buildChunkHashes = (entry, map)=>{
855
856
  const validChunks = (entry.chunks || []).filter((chunk)=>chunk !== runtimeChunkName);
856
857
  validChunks.forEach((chunkName)=>{
857
858
  const chunkInfo = chunks?.find((c)=>c.names?.includes(chunkName));
858
859
  if (chunkInfo) {
859
- const existing = entryToChunkHashesMap.get(entry.testPath) || {};
860
+ const existing = map.get(entry.testPath) || {};
860
861
  existing[chunkName] = chunkInfo.hash ?? '';
861
- entryToChunkHashesMap.set(entry.testPath, existing);
862
+ map.set(entry.testPath, existing);
862
863
  }
863
864
  });
864
865
  };
865
- (entries || []).forEach(buildChunkHashes);
866
+ const processEntryChanges = (_entries, prevHashes, currentHashesMap)=>{
867
+ const affectedPaths = new Set();
868
+ const deletedPaths = [];
869
+ if (prevHashes) {
870
+ const prevMap = new Map(prevHashes.map((e)=>[
871
+ e.name,
872
+ e.chunks
873
+ ]));
874
+ const currentNames = new Set(currentHashesMap.keys());
875
+ deletedPaths.push(...Array.from(prevMap.keys()).filter((name)=>!currentNames.has(name)));
876
+ const findAffectedEntry = (testPath)=>{
877
+ const currentChunks = currentHashesMap.get(testPath);
878
+ const prevChunks = prevMap.get(testPath);
879
+ if (!currentChunks) return;
880
+ if (!prevChunks) return void affectedPaths.add(testPath);
881
+ const hasChanges = Object.entries(currentChunks).some(([chunkName, hash])=>prevChunks[chunkName] !== hash);
882
+ if (hasChanges) affectedPaths.add(testPath);
883
+ };
884
+ currentHashesMap.forEach((_, testPath)=>{
885
+ findAffectedEntry(testPath);
886
+ });
887
+ }
888
+ return {
889
+ affectedPaths,
890
+ deletedPaths
891
+ };
892
+ };
893
+ const previousSetupHashes = buildData.setupEntryToChunkHashes;
894
+ const previousEntryHashes = buildData.entryToChunkHashes;
895
+ const setupEntryToChunkHashesMap = new Map();
896
+ setupEntries.forEach((entry)=>{
897
+ buildChunkHashes(entry, setupEntryToChunkHashesMap);
898
+ });
899
+ const setupEntryToChunkHashes = Array.from(setupEntryToChunkHashesMap.entries()).map(([name, chunks])=>({
900
+ name,
901
+ chunks
902
+ }));
903
+ buildData.setupEntryToChunkHashes = setupEntryToChunkHashes;
904
+ const entryToChunkHashesMap = new Map();
905
+ (entries || []).forEach((entry)=>{
906
+ buildChunkHashes(entry, entryToChunkHashesMap);
907
+ });
866
908
  const entryToChunkHashes = Array.from(entryToChunkHashesMap.entries()).map(([name, chunks])=>({
867
909
  name,
868
910
  chunks
869
911
  }));
870
- const affectedTestPaths = new Set();
871
- const deletedEntries = [];
872
- if (buildData.entryToChunkHashes) {
873
- const prevMap = new Map(buildData.entryToChunkHashes.map((e)=>[
874
- e.name,
875
- e.chunks
876
- ]));
877
- const currentNames = new Set(entryToChunkHashesMap.keys());
878
- deletedEntries.push(...Array.from(prevMap.keys()).filter((name)=>!currentNames.has(name)));
879
- const findAffectedEntry = (testPath)=>{
880
- const currentChunks = entryToChunkHashesMap.get(testPath);
881
- const prevChunks = prevMap.get(testPath);
882
- if (!currentChunks) return;
883
- if (!prevChunks) return void affectedTestPaths.add(testPath);
884
- const hasChanges = Object.entries(currentChunks).some(([chunkName, hash])=>prevChunks[chunkName] !== hash);
885
- if (hasChanges) affectedTestPaths.add(testPath);
886
- };
887
- entryToChunkHashesMap.forEach((_, testPath)=>{
888
- findAffectedEntry(testPath);
889
- });
890
- }
891
912
  buildData.entryToChunkHashes = entryToChunkHashes;
913
+ const isSetupChanged = ()=>{
914
+ const { affectedPaths: affectedSetupPaths, deletedPaths: deletedSetups } = processEntryChanges(setupEntries, previousSetupHashes, setupEntryToChunkHashesMap);
915
+ const affectedSetups = Array.from(affectedSetupPaths).map((testPath)=>setupEntries.find((e)=>e.testPath === testPath)).filter((entry)=>void 0 !== entry);
916
+ return affectedSetups.length > 0 || deletedSetups.length > 0;
917
+ };
918
+ if (isSetupChanged()) return {
919
+ affectedEntries: entries,
920
+ deletedEntries: []
921
+ };
922
+ const { affectedPaths: affectedTestPaths, deletedPaths } = processEntryChanges(entries, previousEntryHashes, entryToChunkHashesMap);
892
923
  const affectedEntries = Array.from(affectedTestPaths).map((testPath)=>entries.find((e)=>e.testPath === testPath)).filter((entry)=>void 0 !== entry);
893
924
  return {
894
925
  affectedEntries,
895
- deletedEntries
926
+ deletedEntries: deletedPaths
896
927
  };
897
928
  };
898
929
  class AssetsMemorySafeMap extends Map {
@@ -902,7 +933,7 @@ class AssetsMemorySafeMap extends Map {
902
933
  return super.set(key, value);
903
934
  }
904
935
  }
905
- const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSetupFiles, rsbuildInstance, inspectedConfig })=>{
936
+ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSetupFiles, rsbuildInstance, inspectedConfig, isWatchMode })=>{
906
937
  let rspackCompiler;
907
938
  const rstestCompilerPlugin = {
908
939
  name: 'rstest:compiler',
@@ -932,13 +963,20 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSe
932
963
  if (!rspackCompiler) throw new Error('rspackCompiler was not initialized');
933
964
  const outputFileSystem = isMultiCompiler(rspackCompiler) ? rspackCompiler.compilers[0].outputFileSystem : rspackCompiler.outputFileSystem;
934
965
  if (!outputFileSystem) throw new Error(`Expect outputFileSystem to be defined, but got ${outputFileSystem}`);
935
- const readFile = async (fileName)=>new Promise((resolve, reject)=>{
966
+ const cachedReadFilePromises = new Map();
967
+ const readFile = async (fileName)=>{
968
+ if (cachedReadFilePromises.has(fileName)) return cachedReadFilePromises.get(fileName);
969
+ const promise = new Promise((resolve, reject)=>{
936
970
  outputFileSystem.readFile(fileName, (err, data)=>{
937
971
  if (err) reject(err);
938
972
  const content = 'string' == typeof data ? data : fileName.endsWith('.wasm') ? data.toString('base64') : data.toString('utf-8');
939
973
  resolve(content);
940
974
  });
941
975
  });
976
+ cachedReadFilePromises.set(fileName, promise);
977
+ promise.finally(()=>cachedReadFilePromises.delete(fileName));
978
+ return promise;
979
+ };
942
980
  const buildData = {};
943
981
  const getEntryFiles = async (manifest, outputPath)=>{
944
982
  const entryFiles = {};
@@ -1015,7 +1053,10 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSe
1015
1053
  ];
1016
1054
  }));
1017
1055
  buildData[environmentName] ??= {};
1018
- const { affectedEntries, deletedEntries } = calcEntriesToRerun(entries, chunks, buildData[environmentName], `${environmentName}-${RUNTIME_CHUNK_NAME}`);
1056
+ const { affectedEntries, deletedEntries } = isWatchMode ? calcEntriesToRerun(entries, chunks, buildData[environmentName], `${environmentName}-${RUNTIME_CHUNK_NAME}`, setupEntries) : {
1057
+ affectedEntries: [],
1058
+ deletedEntries: []
1059
+ };
1019
1060
  const cachedAssetFiles = new AssetsMemorySafeMap();
1020
1061
  const cachedSourceMaps = new AssetsMemorySafeMap();
1021
1062
  const readFileWithCache = async (name)=>{
package/dist/0~8957.js ADDED
@@ -0,0 +1,149 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import { M, T } from "./0~6151.js";
4
+ const isMockFunction = (fn)=>'function' == typeof fn && '_isMockFunction' in fn && fn._isMockFunction;
5
+ const initSpy = ()=>{
6
+ let callOrder = 0;
7
+ const mocks = new Set();
8
+ const wrapSpy = (obj, methodName, mockFn)=>{
9
+ const spyImpl = M(obj, methodName, mockFn);
10
+ const spyFn = spyImpl;
11
+ let mockImplementationOnce = [];
12
+ let implementation = mockFn;
13
+ let mockName = mockFn?.name;
14
+ const initMockState = ()=>({
15
+ instances: [],
16
+ contexts: [],
17
+ invocationCallOrder: []
18
+ });
19
+ let mockState = initMockState();
20
+ const spyState = T(spyImpl);
21
+ spyFn.getMockName = ()=>mockName || methodName;
22
+ spyFn.mockName = (name)=>{
23
+ mockName = name;
24
+ return spyFn;
25
+ };
26
+ spyFn.getMockImplementation = ()=>mockImplementationOnce.length ? mockImplementationOnce[mockImplementationOnce.length - 1] : implementation;
27
+ function withImplementation(fn, cb) {
28
+ const originalImplementation = implementation;
29
+ const originalMockImplementationOnce = mockImplementationOnce;
30
+ implementation = fn;
31
+ mockImplementationOnce = [];
32
+ spyState.willCall(willCall);
33
+ const reset = ()=>{
34
+ implementation = originalImplementation;
35
+ mockImplementationOnce = originalMockImplementationOnce;
36
+ };
37
+ const result = cb();
38
+ if (result instanceof Promise) return result.then(()=>{
39
+ reset();
40
+ });
41
+ reset();
42
+ }
43
+ spyFn.withImplementation = withImplementation;
44
+ spyFn.mockImplementation = (fn)=>{
45
+ implementation = fn;
46
+ return spyFn;
47
+ };
48
+ spyFn.mockImplementationOnce = (fn)=>{
49
+ mockImplementationOnce.push(fn);
50
+ return spyFn;
51
+ };
52
+ spyFn.mockReturnValue = (value)=>spyFn.mockImplementation(()=>value);
53
+ spyFn.mockReturnValueOnce = (value)=>spyFn.mockImplementationOnce(()=>value);
54
+ spyFn.mockResolvedValue = (value)=>spyFn.mockImplementation(()=>Promise.resolve(value));
55
+ spyFn.mockResolvedValueOnce = (value)=>spyFn.mockImplementationOnce(()=>Promise.resolve(value));
56
+ spyFn.mockRejectedValue = (value)=>spyFn.mockImplementation(()=>Promise.reject(value));
57
+ spyFn.mockRejectedValueOnce = (value)=>spyFn.mockImplementationOnce(()=>Promise.reject(value));
58
+ spyFn.mockReturnThis = ()=>spyFn.mockImplementation(function() {
59
+ return this;
60
+ });
61
+ function willCall(...args) {
62
+ let impl = implementation || spyState.getOriginal();
63
+ mockState.instances.push(this);
64
+ mockState.contexts.push(this);
65
+ mockState.invocationCallOrder.push(++callOrder);
66
+ if (mockImplementationOnce.length) impl = mockImplementationOnce.shift();
67
+ return impl?.apply(this, args);
68
+ }
69
+ spyState.willCall(willCall);
70
+ Object.defineProperty(spyFn, 'mock', {
71
+ get: ()=>({
72
+ get calls () {
73
+ return spyState.calls;
74
+ },
75
+ get lastCall () {
76
+ return spyState.calls[spyState.callCount - 1];
77
+ },
78
+ get instances () {
79
+ return mockState.instances;
80
+ },
81
+ get contexts () {
82
+ return mockState.contexts;
83
+ },
84
+ get invocationCallOrder () {
85
+ return mockState.invocationCallOrder;
86
+ },
87
+ get results () {
88
+ return spyState.results.map(([resultType, value])=>{
89
+ const type = 'error' === resultType ? 'throw' : 'return';
90
+ return {
91
+ type: type,
92
+ value
93
+ };
94
+ });
95
+ },
96
+ get settledResults () {
97
+ return spyState.resolves.map(([resultType, value])=>{
98
+ const type = 'error' === resultType ? 'rejected' : 'fulfilled';
99
+ return {
100
+ type,
101
+ value
102
+ };
103
+ });
104
+ }
105
+ })
106
+ });
107
+ spyFn.mockClear = ()=>{
108
+ mockState = initMockState();
109
+ spyState.reset();
110
+ return spyFn;
111
+ };
112
+ spyFn.mockReset = ()=>{
113
+ spyFn.mockClear();
114
+ implementation = mockFn;
115
+ mockImplementationOnce = [];
116
+ return spyFn;
117
+ };
118
+ spyFn.mockRestore = ()=>{
119
+ spyFn.mockReset();
120
+ spyState.restore();
121
+ mockName = mockFn?.name;
122
+ };
123
+ mocks.add(spyFn);
124
+ return spyFn;
125
+ };
126
+ const fn = (mockFn)=>{
127
+ const defaultName = 'rstest.fn()';
128
+ return wrapSpy({
129
+ [defaultName]: mockFn
130
+ }, defaultName, mockFn);
131
+ };
132
+ const spyOn = (obj, methodName, accessType)=>{
133
+ const accessTypeMap = {
134
+ get: 'getter',
135
+ set: 'setter'
136
+ };
137
+ const method = accessType ? {
138
+ [accessTypeMap[accessType]]: methodName
139
+ } : methodName;
140
+ return wrapSpy(obj, method);
141
+ };
142
+ return {
143
+ isMockFunction: isMockFunction,
144
+ spyOn,
145
+ fn,
146
+ mocks
147
+ };
148
+ };
149
+ export { initSpy };
@@ -1,15 +1,18 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./664.js";
4
+ import "./5693.js";
5
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";
6
+ import { getTestEntries, getTaskNameWithPrefix, prettyTestPath, ROOT_SUITE_NAME, bgColor } from "./1157.js";
7
+ import { logger_logger } from "./3278.js";
8
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
12
  const collectTests = async ({ context, globTestSourceEntries })=>{
13
+ const { getSetupFiles } = await import("./0~6973.js").then((mod)=>({
14
+ getSetupFiles: mod.getSetupFiles
15
+ }));
13
16
  const setupFiles = Object.fromEntries(context.projects.map((project)=>{
14
17
  const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
15
18
  return [
@@ -28,6 +31,7 @@ const collectTests = async ({ context, globTestSourceEntries })=>{
28
31
  const { getRsbuildStats, closeServer } = await createRsbuildServer({
29
32
  globTestSourceEntries,
30
33
  globalSetupFiles,
34
+ isWatchMode: false,
31
35
  inspectedConfig: {
32
36
  ...context.normalizedConfig,
33
37
  projects: context.projects.map((p)=>p.normalizedConfig)
@@ -152,7 +156,7 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
152
156
  const hasError = list.some((file)=>file.errors?.length) || errors.length;
153
157
  const showProject = context.projects.length > 1;
154
158
  if (hasError) {
155
- const { printError } = await import("./131.js").then((mod)=>({
159
+ const { printError } = await import("./9131.js").then((mod)=>({
156
160
  printError: mod.error_printError
157
161
  }));
158
162
  process.exitCode = 1;
@@ -167,7 +171,7 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
167
171
  }
168
172
  }
169
173
  if (errors.length) {
170
- const { printError } = await import("./131.js").then((mod)=>({
174
+ const { printError } = await import("./9131.js").then((mod)=>({
171
175
  printError: mod.error_printError
172
176
  }));
173
177
  for (const error of errors || []){
@@ -4,8 +4,8 @@ import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import { fileURLToPath } from "url";
5
5
  import { createRequire } from "module";
6
6
  import promises, { lstat, readdir, realpath, stat as promises_stat, writeFile } from "node:fs/promises";
7
- import { createRequire as external_node_module_createRequire } from "./664.js";
8
- import { normalize, isAbsolute, posix, join, parse } from "./278.js";
7
+ import "./5693.js";
8
+ import { normalize, isAbsolute, posix, join, parse } 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");
@@ -1377,11 +1377,11 @@ __webpack_require__.add({
1377
1377
  exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1378
1378
  exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
1379
1379
  exports.isWindows = ()=>{
1380
- if ('undefined' != typeof navigator && navigator.platform) {
1380
+ if ("u" > typeof navigator && navigator.platform) {
1381
1381
  const platform = navigator.platform.toLowerCase();
1382
1382
  return 'win32' === platform || 'windows' === platform;
1383
1383
  }
1384
- if ('undefined' != typeof process && process.platform) return 'win32' === process.platform;
1384
+ if ("u" > typeof process && process.platform) return 'win32' === process.platform;
1385
1385
  return false;
1386
1386
  };
1387
1387
  exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
@@ -2375,43 +2375,6 @@ const getTestEntries = async ({ include, exclude, rootPath, projectRoot, fileFil
2375
2375
  ];
2376
2376
  }));
2377
2377
  };
2378
- const tryResolve = (request, rootPath)=>{
2379
- try {
2380
- const require = external_node_module_createRequire(rootPath);
2381
- return require.resolve(request, {
2382
- paths: [
2383
- rootPath
2384
- ]
2385
- });
2386
- } catch (_err) {
2387
- return;
2388
- }
2389
- };
2390
- const getSetupFiles = (setups, rootPath)=>{
2391
- if (!setups.length) return {};
2392
- return Object.fromEntries(setups.map((setupFile)=>{
2393
- const setupFilePath = getAbsolutePath(rootPath, setupFile);
2394
- try {
2395
- if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
2396
- let errorMessage = `Setup file ${picocolors_default().red(setupFile)} not found`;
2397
- if (setupFilePath !== setupFile) errorMessage += picocolors_default().gray(` (resolved path: ${setupFilePath})`);
2398
- throw errorMessage;
2399
- }
2400
- const relativePath = posix.relative(rootPath, setupFilePath);
2401
- return [
2402
- formatTestEntryName(relativePath),
2403
- setupFilePath
2404
- ];
2405
- } catch (err) {
2406
- const resolvedPath = tryResolve(setupFile, rootPath);
2407
- if (resolvedPath) return [
2408
- formatTestEntryName(setupFile),
2409
- resolvedPath
2410
- ];
2411
- throw err;
2412
- }
2413
- }));
2414
- };
2415
2378
  const prettyTestPath = (testPath)=>{
2416
2379
  const { dir, base } = parsePosix(testPath);
2417
2380
  return `${'.' !== dir ? picocolors_default().gray(`${dir}/`) : ''}${picocolors_default().cyan(base)}`;
@@ -2422,4 +2385,4 @@ const formatTestPath = (root, testFilePath)=>{
2422
2385
  return prettyTestPath(testPath);
2423
2386
  };
2424
2387
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
2425
- 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, formatTestPath, getAbsolutePath, getSetupFiles, getTaskNameWithPrefix, getTestEntries, glob, globalApis, isDynamicPattern, isObject, isTTY, lstat, needFlagExperimentalDetectModule, prettyTestPath, prettyTime, promises_stat, readdir, realpath, serializableConfig, undoSerializableConfig, writeFile };
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 };