@rstest/core 0.9.4 → 0.9.5

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 (40) hide show
  1. package/LICENSE.md +0 -228
  2. package/dist/0~8843.js +23 -13
  3. package/dist/0~browserLoader.js +1 -1
  4. package/dist/0~browser~1.js +4 -4
  5. package/dist/0~checkThresholds.js +1 -1
  6. package/dist/0~console.js +1 -1
  7. package/dist/0~fake-timers.js +1483 -0
  8. package/dist/0~generate.js +4 -3
  9. package/dist/0~happyDom.js +1 -1
  10. package/dist/0~jsdom.js +1 -1
  11. package/dist/0~listTests.js +3 -3
  12. package/dist/0~loadModule.js +1 -1
  13. package/dist/0~runTests.js +11 -4
  14. package/dist/0~snapshot.js +2140 -0
  15. package/dist/0~snapshot.js.LICENSE.txt +7 -0
  16. package/dist/0~utils.js +1 -1
  17. package/dist/1949.js +2919 -9808
  18. package/dist/1949.js.LICENSE.txt +1 -49
  19. package/dist/3145.js +318 -36
  20. package/dist/4411.js +232 -47
  21. package/dist/6830.js +61 -9
  22. package/dist/7552.js +22 -4918
  23. package/dist/9743.js +1982 -0
  24. package/dist/9784.js +1343 -0
  25. package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
  26. package/dist/browser-runtime/2~fake-timers.js +1653 -0
  27. package/dist/browser-runtime/2~snapshot.js +2138 -0
  28. package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
  29. package/dist/browser-runtime/723.js +2055 -10605
  30. package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
  31. package/dist/browser-runtime/index.d.ts +189 -11
  32. package/dist/browser-runtime/rslib-runtime.js +0 -7
  33. package/dist/browser.d.ts +39 -5
  34. package/dist/browser.js +2 -2
  35. package/dist/globalSetupWorker.js +1 -1
  36. package/dist/index.d.ts +39 -5
  37. package/dist/mockRuntimeCode.js +2 -0
  38. package/dist/worker.d.ts +31 -5
  39. package/dist/worker.js +11 -9
  40. package/package.json +21 -22
package/dist/worker.d.ts CHANGED
@@ -592,7 +592,7 @@ declare type NormalizedBrowserModeConfig = {
592
592
  providerOptions: Record<string, unknown>;
593
593
  };
594
594
 
595
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
595
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
596
596
  pool: RstestPoolOptions;
597
597
  testEnvironment: EnvironmentWithOptions;
598
598
  coverage: NormalizedCoverageOptions;
@@ -603,6 +603,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
603
603
  patterns: string[];
604
604
  override?: boolean;
605
605
  };
606
+ output: NormalizedOutputConfig;
606
607
  };
607
608
 
608
609
  declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
@@ -610,9 +611,16 @@ declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresho
610
611
  include?: string[];
611
612
  };
612
613
 
613
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
614
+ declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
615
+ distPath: {
616
+ root: string;
617
+ };
618
+ };
619
+
620
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
614
621
  setupFiles: string[];
615
622
  globalSetup: string[];
623
+ output?: Omit<NormalizedOutputConfig, 'distPath'>;
616
624
  };
617
625
 
618
626
  declare interface OldPlugin {
@@ -620,7 +628,7 @@ declare interface OldPlugin {
620
628
  test: Test;
621
629
  }
622
630
 
623
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
631
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
624
632
 
625
633
  declare interface Options {
626
634
  logger: {
@@ -670,7 +678,9 @@ declare type Print = (arg0: unknown) => string;
670
678
 
671
679
  declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
672
680
 
673
- declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
681
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
682
+ output?: Omit<RstestOutputConfig, 'distPath'>;
683
+ };
674
684
 
675
685
  declare type ProjectContext = {
676
686
  name: string;
@@ -1017,7 +1027,7 @@ declare interface RstestConfig {
1017
1027
  plugins?: RsbuildConfig['plugins'];
1018
1028
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
1019
1029
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
1020
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
1030
+ output?: RstestOutputConfig;
1021
1031
  resolve?: RsbuildConfig['resolve'];
1022
1032
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
1023
1033
  }
@@ -1060,6 +1070,22 @@ declare type RstestContext = {
1060
1070
  };
1061
1071
  };
1062
1072
 
1073
+ declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
1074
+ distPath?: string | {
1075
+ root?: string;
1076
+ };
1077
+ /**
1078
+ * Whether to bundle third-party dependencies from node_modules.
1079
+ * - `true`: Always bundle all third-party dependencies.
1080
+ * - `false`: Always externalize third-party dependencies.
1081
+ *
1082
+ * When unset, rstest bundles dependencies in browser-like test
1083
+ * environments (jsdom, happy-dom, etc.) and externalizes them in the node
1084
+ * environment. This option is not supported in browser mode.
1085
+ */
1086
+ bundleDependencies?: boolean;
1087
+ };
1088
+
1063
1089
  declare type RstestPoolOptions = {
1064
1090
  /** Pool used to run tests in. */
1065
1091
  type?: RstestPoolType;
package/dist/worker.js CHANGED
@@ -3,10 +3,8 @@ import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import { existsSync, promises } from "node:fs";
4
4
  import "./1255.js";
5
5
  import { createWorkerMetaMessage, createBirpc } from "./1983.js";
6
- import { basename, isAbsolute, color as logger_color, dirname, resolve as pathe_M_eThtNZ_resolve, join } from "./6830.js";
7
- import { createCoverageProvider } from "./7704.js";
6
+ import { basename, isAbsolute, color as logger_color, dirname, globalApis, resolve as pathe_M_eThtNZ_resolve, join } from "./6830.js";
8
7
  import { formatTestError, setRealTimers, getRealTimers } from "./7552.js";
9
- import { globalApis } from "./4411.js";
10
8
  const processSend = process.send.bind(process);
11
9
  const processOn = process.on.bind(process);
12
10
  const processOff = process.off.bind(process);
@@ -122,7 +120,7 @@ const setErrorName = (error, type)=>{
122
120
  };
123
121
  const setupEnv = (env)=>{
124
122
  if (env) Object.entries(env).forEach(([key, value])=>{
125
- if (void 0 === value) delete process.env[key];
123
+ if (void 0 === value) Reflect.deleteProperty(process.env, key);
126
124
  else process.env[key] = value;
127
125
  });
128
126
  };
@@ -308,14 +306,14 @@ const runInPool = async (options)=>{
308
306
  project,
309
307
  testPath,
310
308
  tests,
311
- errors: formatTestError(unhandledErrors)
309
+ errors: await formatTestError(unhandledErrors)
312
310
  };
313
311
  } catch (err) {
314
312
  return {
315
313
  project,
316
314
  testPath,
317
315
  tests: [],
318
- errors: formatTestError(err)
316
+ errors: await formatTestError(err)
319
317
  };
320
318
  } finally{
321
319
  await teardown();
@@ -330,7 +328,11 @@ const runInPool = async (options)=>{
330
328
  name: '',
331
329
  results: []
332
330
  };
333
- const coverageProvider = await createCoverageProvider(options.context.runtimeConfig.coverage || {}, options.context.rootPath);
331
+ let coverageProvider = null;
332
+ if (options.context.runtimeConfig.coverage?.enabled) {
333
+ const { createCoverageProvider } = await import("./7704.js");
334
+ coverageProvider = await createCoverageProvider(options.context.runtimeConfig.coverage, options.context.rootPath);
335
+ }
334
336
  if (coverageProvider) coverageProvider.init();
335
337
  const { assetFiles, sourceMaps: sourceMapsFromAssets } = assets || await rpc.getAssetsByEntry();
336
338
  sourceMaps = sourceMapsFromAssets;
@@ -369,7 +371,7 @@ const runInPool = async (options)=>{
369
371
  }, api);
370
372
  if (unhandledErrors.length > 0) {
371
373
  results.status = 'fail';
372
- results.errors = (results.errors || []).concat(...formatTestError(unhandledErrors));
374
+ results.errors = (results.errors || []).concat(...await formatTestError(unhandledErrors));
373
375
  }
374
376
  if (coverageProvider) {
375
377
  const coverageMap = coverageProvider.collect();
@@ -391,7 +393,7 @@ const runInPool = async (options)=>{
391
393
  status: 'fail',
392
394
  name: '',
393
395
  results: [],
394
- errors: formatTestError(err)
396
+ errors: await formatTestError(err)
395
397
  };
396
398
  } finally{
397
399
  await teardown();
package/package.json CHANGED
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "The Rsbuild-based test tool.",
5
+ "keywords": [
6
+ "rstest",
7
+ "test",
8
+ "rstack",
9
+ "rspack"
10
+ ],
5
11
  "bugs": {
6
12
  "url": "https://github.com/web-infra-dev/rstest/issues"
7
13
  },
@@ -10,19 +16,8 @@
10
16
  "url": "https://github.com/web-infra-dev/rstest",
11
17
  "directory": "packages/core"
12
18
  },
13
- "keywords": [
14
- "rstest",
15
- "test",
16
- "rstack",
17
- "rspack"
18
- ],
19
19
  "license": "MIT",
20
20
  "type": "module",
21
- "main": "./dist/index.js",
22
- "types": "./dist/index.d.ts",
23
- "bin": {
24
- "rstest": "./bin/rstest.js"
25
- },
26
21
  "exports": {
27
22
  ".": {
28
23
  "types": "./dist/index.d.ts",
@@ -46,6 +41,11 @@
46
41
  "types": "./importMeta.d.ts"
47
42
  }
48
43
  },
44
+ "main": "./dist/index.js",
45
+ "types": "./dist/index.d.ts",
46
+ "bin": {
47
+ "rstest": "./bin/rstest.js"
48
+ },
49
49
  "files": [
50
50
  "bin",
51
51
  "dist",
@@ -54,7 +54,7 @@
54
54
  "importMeta.d.ts"
55
55
  ],
56
56
  "dependencies": {
57
- "@rsbuild/core": "2.0.0-beta.9",
57
+ "@rsbuild/core": "2.0.0-beta.10",
58
58
  "@types/chai": "^5.2.3",
59
59
  "tinypool": "^2.1.0"
60
60
  },
@@ -78,21 +78,21 @@
78
78
  "@types/source-map-support": "^0.5.10",
79
79
  "@typescript/native-preview": "7.0.0-dev.20260317.1",
80
80
  "@vitest/expect": "^3.2.4",
81
+ "@vitest/pretty-format": "^3.2.4",
81
82
  "@vitest/snapshot": "^3.2.4",
83
+ "@vitest/utils": "^3.2.4",
82
84
  "birpc": "^4.0.0",
83
85
  "cac": "^7.0.0",
84
86
  "chai": "^6.2.2",
85
87
  "chokidar": "^5.0.0",
86
- "happy-dom": "^20.8.4",
87
- "jest-diff": "^30.3.0",
88
+ "happy-dom": "^20.8.8",
88
89
  "jsdom": "^28.1.0",
89
- "memfs": "^4.56.11",
90
+ "memfs": "^4.57.1",
90
91
  "package-manager-detector": "^1.6.0",
91
92
  "pathe": "^2.0.3",
92
93
  "picocolors": "^1.1.1",
93
- "picomatch": "^4.0.3",
94
- "pretty-format": "^30.3.0",
95
- "rslog": "^2.0.1",
94
+ "picomatch": "^4.0.4",
95
+ "rslog": "^2.1.0",
96
96
  "source-map-support": "^0.5.21",
97
97
  "stacktrace-parser": "0.1.11",
98
98
  "std-env": "^4.0.0",
@@ -102,7 +102,6 @@
102
102
  "url-extras": "^0.1.0",
103
103
  "webpack": "^5.105.4",
104
104
  "webpack-license-plugin": "^4.5.1",
105
- "@rstest/browser-ui": "0.0.0",
106
105
  "@rstest/tsconfig": "0.0.1"
107
106
  },
108
107
  "peerDependencies": {
@@ -126,8 +125,8 @@
126
125
  },
127
126
  "scripts": {
128
127
  "build": "rslib build && npx prettier ./LICENSE.md --write",
129
- "typecheck": "tsc --noEmit",
130
128
  "dev": "cross-env SOURCEMAP=true rslib build --watch",
131
- "test": "npx rstest --globals"
129
+ "test": "npx rstest --globals",
130
+ "typecheck": "tsc --noEmit"
132
131
  }
133
132
  }