@rstest/core 0.3.3 → 0.4.0

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.
@@ -1,5 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
+ import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
3
5
  export const __webpack_id__ = "85";
4
6
  export const __webpack_ids__ = [
5
7
  "85"
@@ -1836,5 +1838,11 @@ export const __webpack_modules__ = {
1836
1838
  __webpack_require__("node:fs/promises");
1837
1839
  __webpack_require__("node:module");
1838
1840
  __webpack_require__("pathe");
1841
+ },
1842
+ chai: function(module) {
1843
+ module.exports = __WEBPACK_EXTERNAL_MODULE_chai__;
1844
+ },
1845
+ "node:fs/promises": function(module) {
1846
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__;
1839
1847
  }
1840
1848
  };
@@ -1,22 +1,22 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- export const __webpack_id__ = "755";
3
+ export const __webpack_id__ = "873";
4
4
  export const __webpack_ids__ = [
5
- "755"
5
+ "873"
6
6
  ];
7
7
  export const __webpack_modules__ = {
8
- "../../node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.es.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8
+ "../../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9
9
  __webpack_require__.r(__webpack_exports__);
10
10
  __webpack_require__.d(__webpack_exports__, {
11
11
  default: ()=>MagicString,
12
12
  Bundle: ()=>Bundle,
13
13
  SourceMap: ()=>SourceMap
14
14
  });
15
- const comma = ','.charCodeAt(0);
16
- const semicolon = ';'.charCodeAt(0);
17
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
18
- const intToChar = new Uint8Array(64);
19
- const charToInt = new Uint8Array(128);
15
+ var comma = ",".charCodeAt(0);
16
+ var semicolon = ";".charCodeAt(0);
17
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
18
+ var intToChar = new Uint8Array(64);
19
+ var charToInt = new Uint8Array(128);
20
20
  for(let i = 0; i < chars.length; i++){
21
21
  const c = chars.charCodeAt(i);
22
22
  intToChar[i] = c;
@@ -33,23 +33,23 @@ export const __webpack_modules__ = {
33
33
  }while (delta > 0);
34
34
  return num;
35
35
  }
36
- const bufLength = 16384;
37
- const td = 'undefined' != typeof TextDecoder ? /* #__PURE__ */ new TextDecoder() : 'undefined' != typeof Buffer ? {
36
+ var bufLength = 16384;
37
+ var td = "undefined" != typeof TextDecoder ? /* @__PURE__ */ new TextDecoder() : "undefined" != typeof Buffer ? {
38
38
  decode (buf) {
39
39
  const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
40
40
  return out.toString();
41
41
  }
42
42
  } : {
43
43
  decode (buf) {
44
- let out = '';
44
+ let out = "";
45
45
  for(let i = 0; i < buf.length; i++)out += String.fromCharCode(buf[i]);
46
46
  return out;
47
47
  }
48
48
  };
49
- class StringWriter {
49
+ var StringWriter = class {
50
50
  constructor(){
51
51
  this.pos = 0;
52
- this.out = '';
52
+ this.out = "";
53
53
  this.buffer = new Uint8Array(bufLength);
54
54
  }
55
55
  write(v) {
@@ -64,7 +64,7 @@ export const __webpack_modules__ = {
64
64
  const { buffer, out, pos } = this;
65
65
  return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
66
66
  }
67
- }
67
+ };
68
68
  function encode(decoded) {
69
69
  const writer = new StringWriter();
70
70
  let sourcesIndex = 0;
@@ -542,6 +542,7 @@ export const __webpack_modules__ = {
542
542
  else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
543
543
  if (chunk.outro.length) mappings.advance(chunk.outro);
544
544
  });
545
+ if (this.outro) mappings.advance(this.outro);
545
546
  return {
546
547
  file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
547
548
  sources: [
@@ -872,10 +873,13 @@ export const __webpack_modules__ = {
872
873
  _split(index) {
873
874
  if (this.byStart[index] || this.byEnd[index]) return;
874
875
  let chunk = this.lastSearchedChunk;
876
+ let previousChunk = chunk;
875
877
  const searchForward = index > chunk.end;
876
878
  while(chunk){
877
879
  if (chunk.contains(index)) return this._splitChunk(chunk, index);
878
880
  chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
881
+ if (chunk === previousChunk) return;
882
+ previousChunk = chunk;
879
883
  }
880
884
  }
881
885
  _splitChunk(chunk, index) {
@@ -1005,7 +1009,10 @@ export const __webpack_modules__ = {
1005
1009
  _replaceString(string, replacement) {
1006
1010
  const { original } = this;
1007
1011
  const index = original.indexOf(string);
1008
- if (-1 !== index) this.overwrite(index, index + string.length, replacement);
1012
+ if (-1 !== index) {
1013
+ if ('function' == typeof replacement) replacement = replacement(string, index, original);
1014
+ if (string !== replacement) this.overwrite(index, index + string.length, replacement);
1015
+ }
1009
1016
  return this;
1010
1017
  }
1011
1018
  replace(searchValue, replacement) {
@@ -1017,7 +1024,9 @@ export const __webpack_modules__ = {
1017
1024
  const stringLength = string.length;
1018
1025
  for(let index = original.indexOf(string); -1 !== index; index = original.indexOf(string, index + stringLength)){
1019
1026
  const previous = original.slice(index, index + stringLength);
1020
- if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
1027
+ let _replacement = replacement;
1028
+ if ('function' == typeof replacement) _replacement = replacement(previous, index, original);
1029
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1021
1030
  }
1022
1031
  return this;
1023
1032
  }
@@ -1,4 +1,4 @@
1
- /*! For license information please see 928.js.LICENSE.txt */
1
+ /*! For license information please see 0~928.js.LICENSE.txt */
2
2
  import 'module';
3
3
  /*#__PURE__*/ import.meta.url;
4
4
  export const __webpack_id__ = "928";
@@ -7,11 +7,7 @@ export const __webpack_ids__ = [
7
7
  ];
8
8
  export const __webpack_modules__ = {
9
9
  "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10
- __webpack_require__.r(__webpack_exports__);
11
10
  __webpack_require__.d(__webpack_exports__, {
12
- WatchHelper: ()=>WatchHelper,
13
- FSWatcher: ()=>FSWatcher,
14
- default: ()=>chokidar_esm,
15
11
  watch: ()=>watch
16
12
  });
17
13
  var external_node_fs_ = __webpack_require__("node:fs");
@@ -1432,9 +1428,5 @@ export const __webpack_modules__ = {
1432
1428
  watcher.add(paths);
1433
1429
  return watcher;
1434
1430
  }
1435
- const chokidar_esm = {
1436
- watch,
1437
- FSWatcher
1438
- };
1439
1431
  }
1440
1432
  };
@@ -1,8 +1,14 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- export const __webpack_id__ = "985";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_birpc__ from "birpc";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_tinypool__ from "tinypool";
8
+ import * as __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__ from "node:inspector";
9
+ export const __webpack_id__ = "938";
4
10
  export const __webpack_ids__ = [
5
- "985"
11
+ "938"
6
12
  ];
7
13
  export const __webpack_modules__ = {
8
14
  "./src/core/rsbuild.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -245,8 +251,7 @@ export const __webpack_modules__ = {
245
251
  });
246
252
  }
247
253
  };
248
- var external_node_inspector_ = __webpack_require__("node:inspector");
249
- const enable = void 0 !== external_node_inspector_["default"].url();
254
+ const enable = void 0 !== __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__["default"].url();
250
255
  const pluginInspect = ()=>enable ? {
251
256
  name: 'rstest:inspect',
252
257
  setup: (api)=>{
@@ -451,7 +456,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
451
456
  }
452
457
  const isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
453
458
  const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
454
- const { command, normalizedConfig: { isolate, dev = {} } } = context;
459
+ const { command, normalizedConfig: { isolate, dev = {}, coverage } } = context;
455
460
  const debugMode = (0, utils._o)();
456
461
  core_.logger.level = debugMode ? 'verbose' : 'error';
457
462
  const writeToDisk = dev.writeToDisk || debugMode;
@@ -498,6 +503,16 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
498
503
  ].filter(Boolean)
499
504
  }
500
505
  });
506
+ if (coverage?.enabled && 'list' !== command) {
507
+ const { loadCoverageProvider } = await __webpack_require__.e("603").then(__webpack_require__.bind(__webpack_require__, "./src/coverage/index.ts"));
508
+ const { pluginCoverageCore } = await __webpack_require__.e("836").then(__webpack_require__.bind(__webpack_require__, "./src/coverage/plugin.ts"));
509
+ const { pluginCoverage } = await loadCoverageProvider(coverage, context.rootPath);
510
+ coverage.exclude.push(...Object.values(setupFiles).flatMap((files)=>Object.values(files)));
511
+ rsbuildInstance.addPlugins([
512
+ pluginCoverage(coverage),
513
+ pluginCoverageCore(coverage)
514
+ ]);
515
+ }
501
516
  return rsbuildInstance;
502
517
  };
503
518
  const calcEntriesToRerun = (entries, chunks, buildData, runtimeChunkName)=>{
@@ -680,16 +695,12 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
680
695
  });
681
696
  var external_node_os_ = __webpack_require__("node:os");
682
697
  var utils = __webpack_require__("./src/utils/index.ts");
683
- var external_node_events_ = __webpack_require__("node:events");
684
698
  var external_node_url_ = __webpack_require__("node:url");
685
- var external_node_v8_ = __webpack_require__("node:v8");
686
- var external_birpc_ = __webpack_require__("birpc");
687
699
  var external_pathe_ = __webpack_require__("pathe");
688
- var external_tinypool_ = __webpack_require__("tinypool");
689
700
  const forks_filename = (0, external_node_url_.fileURLToPath)(import.meta.url);
690
701
  const forks_dirname = (0, external_pathe_.dirname)(forks_filename);
691
702
  function createChannel(rpcMethods) {
692
- const emitter = new external_node_events_["default"]();
703
+ const emitter = new __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__["default"]();
693
704
  const cleanup = ()=>emitter.removeAllListeners();
694
705
  const events = {
695
706
  message: 'message',
@@ -703,9 +714,9 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
703
714
  emitter.emit(events.response, message);
704
715
  }
705
716
  };
706
- (0, external_birpc_.createBirpc)(rpcMethods, {
707
- serialize: external_node_v8_["default"].serialize,
708
- deserialize: (v)=>external_node_v8_["default"].deserialize(Buffer.from(v)),
717
+ (0, __WEBPACK_EXTERNAL_MODULE_birpc__.createBirpc)(rpcMethods, {
718
+ serialize: __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__["default"].serialize,
719
+ deserialize: (v)=>__WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__["default"].deserialize(Buffer.from(v)),
709
720
  post (v) {
710
721
  emitter.emit(events.message, v);
711
722
  },
@@ -730,7 +741,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
730
741
  concurrentTasksPerWorker: 1,
731
742
  isolateWorkers: isolate
732
743
  };
733
- const pool = new external_tinypool_.Tinypool(options);
744
+ const pool = new __WEBPACK_EXTERNAL_MODULE_tinypool__.Tinypool(options);
734
745
  return {
735
746
  name: 'forks',
736
747
  runTest: async ({ options, rpcMethods })=>{
@@ -767,7 +778,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
767
778
  return parsed > 0 ? parsed : 1;
768
779
  };
769
780
  const getRuntimeConfig = (context)=>{
770
- const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment, hookTimeout, isolate } = context.normalizedConfig;
781
+ const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment, hookTimeout, isolate, coverage } = context.normalizedConfig;
771
782
  return {
772
783
  testNamePattern,
773
784
  testTimeout,
@@ -784,7 +795,8 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
784
795
  printConsoleTrace,
785
796
  disableConsoleIntercept,
786
797
  testEnvironment,
787
- isolate
798
+ isolate,
799
+ coverage
788
800
  };
789
801
  };
790
802
  const filterAssetsByEntry = (entryInfo, assetFiles, setupAssets, sourceMaps, entryLength)=>{
@@ -852,6 +864,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
852
864
  context: {
853
865
  project: projectName,
854
866
  rootPath: context.rootPath,
867
+ projectRoot: project.rootPath,
855
868
  runtimeConfig: (0, utils.Ok)(runtimeConfig)
856
869
  },
857
870
  type: 'run',
@@ -896,6 +909,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
896
909
  context: {
897
910
  project: projectName,
898
911
  rootPath: context.rootPath,
912
+ projectRoot: project.rootPath,
899
913
  runtimeConfig: (0, utils.Ok)(runtimeConfig)
900
914
  },
901
915
  type: 'collect',
@@ -920,5 +934,8 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
920
934
  close: ()=>pool.close()
921
935
  };
922
936
  };
937
+ },
938
+ "node:url": function(module) {
939
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__;
923
940
  }
924
941
  };
@@ -16,7 +16,10 @@ export const __webpack_modules__ = {
16
16
  const GLOB_REGEX = /[*?{}[\]()!@+|]/;
17
17
  const isGlob = (str)=>GLOB_REGEX.test(str);
18
18
  async function createChokidar(pathOrGlobs, root, options) {
19
- const chokidar = await __webpack_require__.e("928").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
19
+ const chokidar = await Promise.all([
20
+ __webpack_require__.e("928"),
21
+ __webpack_require__.e("414")
22
+ ]).then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
20
23
  const watchFiles = new Set();
21
24
  const globPatterns = pathOrGlobs.filter((pathOrGlob)=>{
22
25
  if (isGlob(pathOrGlob)) return true;
@@ -24,7 +27,7 @@ export const __webpack_modules__ = {
24
27
  return false;
25
28
  });
26
29
  if (globPatterns.length) {
27
- const { glob } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs"));
30
+ const { glob } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/tinyglobby@0.2.15/node_modules/tinyglobby/dist/index.mjs"));
28
31
  const files = await glob(globPatterns, {
29
32
  cwd: root,
30
33
  absolute: true