@rstest/core 0.0.2 → 0.0.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.
package/dist/353.js CHANGED
@@ -451,7 +451,7 @@ export const __webpack_modules__ = {
451
451
  });
452
452
  return {
453
453
  command,
454
- version: "0.0.2",
454
+ version: "0.0.3",
455
455
  rootPath,
456
456
  reporters,
457
457
  snapshotManager,
package/dist/813.js CHANGED
@@ -131,6 +131,7 @@ export const __webpack_modules__ = {
131
131
  });
132
132
  var helper = __webpack_require__("./src/utils/helper.ts");
133
133
  __webpack_require__("./src/utils/logger.ts");
134
+ __webpack_require__("node:fs");
134
135
  __webpack_require__("node:fs/promises");
135
136
  __webpack_require__("pathe");
136
137
  var constants = __webpack_require__("./src/utils/constants.ts");
package/dist/867.js CHANGED
@@ -1727,6 +1727,7 @@ export const __webpack_modules__ = {
1727
1727
  });
1728
1728
  var helper = __webpack_require__("./src/utils/helper.ts");
1729
1729
  __webpack_require__("./src/utils/logger.ts");
1730
+ __webpack_require__("node:fs");
1730
1731
  __webpack_require__("node:fs/promises");
1731
1732
  __webpack_require__("pathe");
1732
1733
  var constants = __webpack_require__("./src/utils/constants.ts");
package/dist/992.js CHANGED
@@ -37,27 +37,27 @@ export const __webpack_modules__ = {
37
37
  ...setupFiles
38
38
  };
39
39
  };
40
+ config.watchOptions ??= {};
41
+ config.watchOptions.ignored = (0, utils.XQ)(config.watchOptions.ignored || []);
42
+ if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
43
+ config.watchOptions.ignored.push(utils.f1);
40
44
  } else {
45
+ config.watch = false;
46
+ config.watchOptions ??= {};
47
+ config.watchOptions.ignored = '**/**';
41
48
  const sourceEntries = await globTestSourceEntries();
42
49
  config.entry = {
43
50
  ...sourceEntries,
44
51
  ...setupFiles
45
52
  };
46
53
  }
47
- config.watchOptions ??= {};
48
- config.watchOptions.ignored = (0, utils.XQ)(config.watchOptions.ignored || []);
49
- if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
50
- config.watchOptions.ignored.push(utils.f1);
51
54
  });
52
55
  }
53
56
  });
54
57
  class IgnoreModuleNotFoundErrorPlugin {
55
58
  apply(compiler) {
56
59
  compiler.hooks.done.tap('Rstest:IgnoreModuleNotFoundPlugin', (stats)=>{
57
- stats.compilation.errors = stats.compilation.errors.filter((error)=>{
58
- if (/Module not found/.test(error.message)) return false;
59
- return true;
60
- });
60
+ for(let i = stats.compilation.errors.length - 1; i >= 0; i--)if (/Module not found/.test(stats.compilation.errors[i].message)) stats.compilation.errors.splice(i, 1);
61
61
  });
62
62
  }
63
63
  }
@@ -90,8 +90,9 @@ export const __webpack_modules__ = {
90
90
  };
91
91
  const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
92
92
  const { command, normalizedConfig: { name, plugins, resolve, source, output, tools, testEnvironment } } = context;
93
- core_.logger.level = (0, utils.L1)() ? 'verbose' : 'error';
94
- const writeToDisk = 'true' === process.env.DEBUG_RSTEST_OUTPUTS;
93
+ const debugMode = (0, utils.L1)();
94
+ core_.logger.level = debugMode ? 'verbose' : 'error';
95
+ const writeToDisk = debugMode;
95
96
  const rsbuildInstance = await (0, core_.createRsbuild)({
96
97
  rsbuildConfig: {
97
98
  tools,
@@ -138,8 +139,11 @@ export const __webpack_modules__ = {
138
139
  node: true
139
140
  };
140
141
  config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
141
- config.plugins.push(new core_.rspack.RstestPlugin({
142
- injectModulePathName: true
142
+ config.plugins.push(new core_.rspack.experiments.RstestPlugin({
143
+ injectModulePathName: true,
144
+ hoistMockModule: true,
145
+ importMetaPathName: true,
146
+ manualMockRoot: context.rootPath
143
147
  }));
144
148
  config.module.parser ??= {};
145
149
  config.module.parser.javascript = {
@@ -158,6 +162,9 @@ export const __webpack_modules__ = {
158
162
  ...config.optimization || {},
159
163
  moduleIds: 'named',
160
164
  chunkIds: 'named',
165
+ runtimeChunk: {
166
+ name: 'runtime'
167
+ },
161
168
  splitChunks: {
162
169
  chunks: 'all',
163
170
  minSize: 0,
package/dist/cli.js CHANGED
@@ -2382,6 +2382,7 @@ var __webpack_modules__ = {
2382
2382
  });
2383
2383
  var helper = __webpack_require__("./src/utils/helper.ts");
2384
2384
  var logger = __webpack_require__("./src/utils/logger.ts");
2385
+ var external_node_fs_ = __webpack_require__("node:fs");
2385
2386
  var promises_ = __webpack_require__("node:fs/promises");
2386
2387
  var external_pathe_ = __webpack_require__("pathe");
2387
2388
  var dist = __webpack_require__("../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs");
@@ -2398,6 +2399,7 @@ var __webpack_modules__ = {
2398
2399
  });
2399
2400
  };
2400
2401
  const hasInSourceTestCode = (code)=>code.includes('import.meta.rstest');
2402
+ const formatTestEntryName = (name)=>name.replace(/\.*[/\\]/g, '_').replace(/\./g, '~');
2401
2403
  const getTestEntries = async ({ include, exclude, root, fileFilters, includeSource })=>{
2402
2404
  const testFiles = await (0, dist.zA)(include, {
2403
2405
  cwd: root,
@@ -2424,18 +2426,23 @@ var __webpack_modules__ = {
2424
2426
  }));
2425
2427
  }
2426
2428
  return Object.fromEntries(filterFiles(testFiles, fileFilters, root).map((entry)=>{
2427
- const name = external_pathe_["default"].relative(root, entry);
2429
+ const relativePath = external_pathe_["default"].relative(root, entry);
2428
2430
  return [
2429
- name,
2431
+ formatTestEntryName(relativePath),
2430
2432
  entry
2431
2433
  ];
2432
2434
  }));
2433
2435
  };
2434
2436
  const getSetupFiles = (setups, rootPath)=>Object.fromEntries((0, helper.XQ)(setups).map((setupFile)=>{
2435
2437
  const setupFilePath = (0, helper.ZY)(rootPath, setupFile);
2436
- const name = external_pathe_["default"].relative(rootPath, setupFilePath);
2438
+ if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
2439
+ let errorMessage = `Setup file ${helper.$_.red(setupFile)} not found`;
2440
+ if (setupFilePath !== setupFile) errorMessage += helper.$_.gray(` (resolved path: ${setupFilePath})`);
2441
+ throw errorMessage;
2442
+ }
2443
+ const relativePath = external_pathe_["default"].relative(rootPath, setupFilePath);
2437
2444
  return [
2438
- name,
2445
+ formatTestEntryName(relativePath),
2439
2446
  setupFilePath
2440
2447
  ];
2441
2448
  }));
@@ -3580,7 +3587,7 @@ function prepareCli() {
3580
3587
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3581
3588
  }
3582
3589
  function showRstest() {
3583
- logger.k.greet(" Rstest v0.0.2");
3590
+ logger.k.greet(" Rstest v0.0.3");
3584
3591
  logger.k.log('');
3585
3592
  }
3586
3593
  const applyCommonOptions = (cli)=>{
@@ -3624,7 +3631,7 @@ async function initCli(options) {
3624
3631
  function setupCommands() {
3625
3632
  const cli = dist('rstest');
3626
3633
  cli.help();
3627
- cli.version("0.0.2");
3634
+ cli.version("0.0.3");
3628
3635
  applyCommonOptions(cli);
3629
3636
  cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
3630
3637
  showRstest();
package/dist/worker.js CHANGED
@@ -7,6 +7,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
8
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
10
11
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
11
12
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
12
13
  import * as __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__ from "node:timers";
@@ -5391,6 +5392,9 @@ var __webpack_modules__ = {
5391
5392
  "node:console": function(module) {
5392
5393
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
5393
5394
  },
5395
+ "node:fs": function(module) {
5396
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
5397
+ },
5394
5398
  "node:fs/promises": function(module) {
5395
5399
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__;
5396
5400
  },
@@ -5600,7 +5604,7 @@ const loadModule_createRequire = (filename, distPath, rstestContext, assetFiles,
5600
5604
  const joinedPath = isRelativePath(id) ? external_pathe_["default"].join(currentDirectory, id) : id;
5601
5605
  const content = assetFiles[joinedPath];
5602
5606
  if (content) try {
5603
- return loadModule({
5607
+ return cacheableLoadModule({
5604
5608
  codeContent: content,
5605
5609
  testPath: joinedPath,
5606
5610
  distPath: joinedPath,
@@ -5661,6 +5665,20 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
5661
5665
  fn(...Object.values(context));
5662
5666
  return localModule.exports;
5663
5667
  };
5668
+ const moduleCache = new Map();
5669
+ const cacheableLoadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
5670
+ if (moduleCache.has(testPath)) return moduleCache.get(testPath);
5671
+ const mod = loadModule({
5672
+ codeContent,
5673
+ distPath,
5674
+ testPath,
5675
+ rstestContext,
5676
+ assetFiles,
5677
+ interopDefault
5678
+ });
5679
+ moduleCache.set(testPath, mod);
5680
+ return mod;
5681
+ };
5664
5682
  const processSend = process.send.bind(process);
5665
5683
  const processOn = process.on.bind(process);
5666
5684
  const processOff = process.off.bind(process);
@@ -5777,7 +5795,7 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
5777
5795
  const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault })=>{
5778
5796
  for (const { distPath, testPath } of setupEntries){
5779
5797
  const setupCodeContent = assetFiles[distPath];
5780
- await loadModule({
5798
+ await cacheableLoadModule({
5781
5799
  codeContent: setupCodeContent,
5782
5800
  distPath,
5783
5801
  testPath,
@@ -5786,7 +5804,7 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5786
5804
  interopDefault
5787
5805
  });
5788
5806
  }
5789
- await loadModule({
5807
+ await cacheableLoadModule({
5790
5808
  codeContent: assetFiles[distPath],
5791
5809
  distPath,
5792
5810
  testPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "The Rsbuild-based test tool.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/web-infra-dev/rstest/issues"
@@ -48,7 +48,7 @@
48
48
  "importMeta.d.ts"
49
49
  ],
50
50
  "dependencies": {
51
- "@rsbuild/core": "^1.4.0-beta.5",
51
+ "@rsbuild/core": "1.4.0-rc.0",
52
52
  "@types/chai": "^5.2.2",
53
53
  "@vitest/expect": "^3.2.4",
54
54
  "@vitest/snapshot": "^3.2.4",
@@ -73,7 +73,7 @@
73
73
  "jest-diff": "^30.0.2",
74
74
  "license-webpack-plugin": "^4.0.2",
75
75
  "picocolors": "^1.1.1",
76
- "rslog": "^1.2.7",
76
+ "rslog": "^1.2.8",
77
77
  "source-map-support": "^0.5.21",
78
78
  "stacktrace-parser": "0.1.11",
79
79
  "tinyglobby": "^0.2.14",