@rstest/core 0.9.3 → 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 (42) hide show
  1. package/LICENSE.md +0 -228
  2. package/dist/0~8843.js +33 -17
  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 +14 -10
  12. package/dist/0~loadEsModule.js +3 -1
  13. package/dist/0~loadModule.js +1 -1
  14. package/dist/0~runTests.js +17 -6
  15. package/dist/0~snapshot.js +2140 -0
  16. package/dist/0~snapshot.js.LICENSE.txt +7 -0
  17. package/dist/0~utils.js +1 -1
  18. package/dist/1949.js +2919 -9808
  19. package/dist/1949.js.LICENSE.txt +1 -49
  20. package/dist/3145.js +363 -63
  21. package/dist/4411.js +232 -47
  22. package/dist/6830.js +61 -9
  23. package/dist/7552.js +22 -4918
  24. package/dist/7704.js +1 -2
  25. package/dist/9743.js +1982 -0
  26. package/dist/9784.js +1343 -0
  27. package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
  28. package/dist/browser-runtime/2~fake-timers.js +1653 -0
  29. package/dist/browser-runtime/2~snapshot.js +2138 -0
  30. package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
  31. package/dist/browser-runtime/723.js +2055 -10605
  32. package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
  33. package/dist/browser-runtime/index.d.ts +189 -11
  34. package/dist/browser-runtime/rslib-runtime.js +0 -7
  35. package/dist/browser.d.ts +39 -5
  36. package/dist/browser.js +2 -2
  37. package/dist/globalSetupWorker.js +1 -1
  38. package/dist/index.d.ts +39 -5
  39. package/dist/mockRuntimeCode.js +2 -0
  40. package/dist/worker.d.ts +31 -5
  41. package/dist/worker.js +32 -11
  42. package/package.json +21 -22
@@ -1,20 +1,3 @@
1
- /*
2
- * @version 1.4.0
3
- * @date 2015-10-26
4
- * @stability 3 - Stable
5
- * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
6
- * @license MIT License
7
- */
8
-
9
- /*!
10
- * /**
11
- * * Copyright (c) Meta Platforms, Inc. and affiliates.
12
- * *
13
- * * This source code is licensed under the MIT license found in the
14
- * * LICENSE file in the root directory of this source tree.
15
- * * /
16
- */
17
-
18
1
  /*!
19
2
  * Chai - addChainingMethod utility
20
3
  * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
@@ -1,14 +1,8 @@
1
1
  import type { assert as assert_2 } from 'chai';
2
2
  import type { config } from 'chai';
3
- import { Constructable } from '@vitest/utils';
4
- import { diff } from '@vitest/utils/diff';
5
3
  import { Formatter } from 'tinyrainbow';
6
4
  import { MockInstance } from '@vitest/spy';
7
- import { OptionsReceived } from '@vitest/pretty-format';
8
- import { Plugin as Plugin_2 } from '@vitest/pretty-format';
9
- import { printDiffOrStringify } from '@vitest/utils/diff';
10
5
  import type { RsbuildConfig } from '@rsbuild/core';
11
- import { stringify } from '@vitest/utils';
12
6
  import type { Writable } from 'node:stream';
13
7
 
14
8
  /**
@@ -379,6 +373,58 @@ declare interface CloverOptions extends FileOptions, ProjectOptions {}
379
373
 
380
374
  declare interface CoberturaOptions extends FileOptions, ProjectOptions {}
381
375
 
376
+ /**
377
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
378
+ *
379
+ * This source code is licensed under the MIT license found in the
380
+ * LICENSE file in the root directory of this source tree.
381
+ */
382
+ declare interface Colors {
383
+ comment: {
384
+ close: string
385
+ open: string
386
+ };
387
+ content: {
388
+ close: string
389
+ open: string
390
+ };
391
+ prop: {
392
+ close: string
393
+ open: string
394
+ };
395
+ tag: {
396
+ close: string
397
+ open: string
398
+ };
399
+ value: {
400
+ close: string
401
+ open: string
402
+ };
403
+ }
404
+
405
+ declare type CompareKeys = ((a: string, b: string) => number) | null | undefined;
406
+
407
+ declare interface Config {
408
+ callToJSON: boolean;
409
+ compareKeys: CompareKeys;
410
+ colors: Colors;
411
+ escapeRegex: boolean;
412
+ escapeString: boolean;
413
+ indent: string;
414
+ maxDepth: number;
415
+ maxWidth: number;
416
+ min: boolean;
417
+ plugins: Plugins;
418
+ printBasicPrototype: boolean;
419
+ printFunctionName: boolean;
420
+ spacingInner: string;
421
+ spacingOuter: string;
422
+ }
423
+
424
+ declare interface Constructable {
425
+ new (...args: any[]): any;
426
+ }
427
+
382
428
  declare type Constructor<T = any> = new (...args: any[]) => T;
383
429
 
384
430
  /**
@@ -684,6 +730,49 @@ declare interface DescribeForFn {
684
730
  */
685
731
  declare type DevicePreset = 'iPhoneSE' | 'iPhoneXR' | 'iPhone12Pro' | 'iPhone14ProMax' | 'Pixel7' | 'SamsungGalaxyS8Plus' | 'SamsungGalaxyS20Ultra' | 'iPadMini' | 'iPadAir' | 'iPadPro' | 'SurfacePro7' | 'SurfaceDuo' | 'GalaxyZFold5' | 'AsusZenbookFold' | 'SamsungGalaxyA51A71' | 'NestHub' | 'NestHubMax';
686
732
 
733
+ /**
734
+ * @param a Expected value
735
+ * @param b Received value
736
+ * @param options Diff options
737
+ * @returns {string | null} a string diff
738
+ */
739
+ declare function diff(a: any, b: any, options?: DiffOptions): string | undefined;
740
+
741
+ declare interface DiffOptions {
742
+ aAnnotation?: string;
743
+ aColor?: DiffOptionsColor;
744
+ aIndicator?: string;
745
+ bAnnotation?: string;
746
+ bColor?: DiffOptionsColor;
747
+ bIndicator?: string;
748
+ changeColor?: DiffOptionsColor;
749
+ changeLineTrailingSpaceColor?: DiffOptionsColor;
750
+ commonColor?: DiffOptionsColor;
751
+ commonIndicator?: string;
752
+ commonLineTrailingSpaceColor?: DiffOptionsColor;
753
+ contextLines?: number;
754
+ emptyFirstOrLastLinePlaceholder?: string;
755
+ expand?: boolean;
756
+ includeChangeCounts?: boolean;
757
+ omitAnnotationLines?: boolean;
758
+ patchColor?: DiffOptionsColor;
759
+ printBasicPrototype?: boolean;
760
+ maxDepth?: number;
761
+ compareKeys?: CompareKeys;
762
+ truncateThreshold?: number;
763
+ truncateAnnotation?: string;
764
+ truncateAnnotationColor?: DiffOptionsColor;
765
+ }
766
+
767
+ /**
768
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
769
+ *
770
+ * This source code is licensed under the MIT license found in the
771
+ * LICENSE file in the root directory of this source tree.
772
+ */
773
+
774
+ declare type DiffOptionsColor = (arg: string) => string;
775
+
687
776
  /** The test file output path */
688
777
  declare type DistPath = string;
689
778
 
@@ -929,6 +1018,8 @@ declare interface HtmlSpaOptions extends HtmlOptions {
929
1018
  metricsToShow: Array<"lines" | "branches" | "functions" | "statements">;
930
1019
  }
931
1020
 
1021
+ declare type Indent = (arg0: string) => string;
1022
+
932
1023
  /**
933
1024
  * A list of glob patterns or files that match your test projects.
934
1025
  *
@@ -1726,6 +1817,11 @@ declare interface MockSettledResultRejected {
1726
1817
 
1727
1818
  declare type NamesIndex = number;
1728
1819
 
1820
+ declare interface NewPlugin {
1821
+ serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
1822
+ test: Test_2;
1823
+ }
1824
+
1729
1825
  declare interface Node_2 {
1730
1826
  isRoot(): boolean;
1731
1827
  visit(visitor: Visitor, state: any): void;
@@ -1742,7 +1838,7 @@ declare type NormalizedBrowserModeConfig = {
1742
1838
  providerOptions: Record<string, unknown>;
1743
1839
  };
1744
1840
 
1745
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
1841
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
1746
1842
  pool: RstestPoolOptions;
1747
1843
  testEnvironment: EnvironmentWithOptions;
1748
1844
  coverage: NormalizedCoverageOptions;
@@ -1753,6 +1849,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
1753
1849
  patterns: string[];
1754
1850
  override?: boolean;
1755
1851
  };
1852
+ output: NormalizedOutputConfig;
1756
1853
  };
1757
1854
 
1758
1855
  declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
@@ -1769,13 +1866,25 @@ declare type NormalizedFixture = {
1769
1866
 
1770
1867
  declare type NormalizedFixtures = Record<string, NormalizedFixture>;
1771
1868
 
1869
+ declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
1870
+ distPath: {
1871
+ root: string;
1872
+ };
1873
+ };
1874
+
1772
1875
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
1773
1876
 
1774
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
1877
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
1775
1878
  setupFiles: string[];
1776
1879
  globalSetup: string[];
1880
+ output?: Omit<NormalizedOutputConfig, 'distPath'>;
1777
1881
  };
1778
1882
 
1883
+ declare interface OldPlugin {
1884
+ print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
1885
+ test: Test_2;
1886
+ }
1887
+
1779
1888
  export declare const onTestFailed: Rstest['onTestFailed'];
1780
1889
 
1781
1890
  declare type OnTestFailedHandler = (ctx: TestContext) => MaybePromise<void>;
@@ -1784,7 +1893,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
1784
1893
 
1785
1894
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
1786
1895
 
1787
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
1896
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
1788
1897
 
1789
1898
  declare interface Options {
1790
1899
  logger: {
@@ -1796,6 +1905,8 @@ declare interface Options {
1796
1905
  getWindow: () => string[];
1797
1906
  }
1798
1907
 
1908
+ declare type OptionsReceived = PrettyFormatOptions;
1909
+
1799
1910
  declare interface ParsedStack {
1800
1911
  method: string;
1801
1912
  file: string;
@@ -1803,6 +1914,37 @@ declare interface ParsedStack {
1803
1914
  column: number;
1804
1915
  }
1805
1916
 
1917
+ declare type Plugin_2 = NewPlugin | OldPlugin;
1918
+
1919
+ declare interface PluginOptions {
1920
+ edgeSpacing: string;
1921
+ min: boolean;
1922
+ spacing: string;
1923
+ }
1924
+
1925
+ declare type Plugins = Array<Plugin_2>;
1926
+
1927
+ declare interface PrettyFormatOptions {
1928
+ callToJSON?: boolean;
1929
+ escapeRegex?: boolean;
1930
+ escapeString?: boolean;
1931
+ highlight?: boolean;
1932
+ indent?: number;
1933
+ maxDepth?: number;
1934
+ maxWidth?: number;
1935
+ min?: boolean;
1936
+ printBasicPrototype?: boolean;
1937
+ printFunctionName?: boolean;
1938
+ compareKeys?: CompareKeys;
1939
+ plugins?: Plugins;
1940
+ }
1941
+
1942
+ declare type Print = (arg0: unknown) => string;
1943
+
1944
+ declare function printDiffOrStringify(received: unknown, expected: unknown, options?: DiffOptions): string | undefined;
1945
+
1946
+ declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
1947
+
1806
1948
  declare function printExpected(value: unknown): string;
1807
1949
 
1808
1950
  declare function printReceived(object: unknown): string;
@@ -1811,7 +1953,9 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
1811
1953
 
1812
1954
  declare type Procedure = (...args: any[]) => any;
1813
1955
 
1814
- declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
1956
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
1957
+ output?: Omit<RstestOutputConfig, 'distPath'>;
1958
+ };
1815
1959
 
1816
1960
  declare type ProjectContext = {
1817
1961
  name: string;
@@ -1861,6 +2005,8 @@ declare interface RawSnapshotInfo {
1861
2005
  content?: string;
1862
2006
  }
1863
2007
 
2008
+ declare type Refs = Array<unknown>;
2009
+
1864
2010
  declare class ReportBase {
1865
2011
  constructor(options?: Partial<ReportBaseOptions>);
1866
2012
  execute(context: Context): void;
@@ -2194,7 +2340,7 @@ declare interface RstestConfig {
2194
2340
  plugins?: RsbuildConfig['plugins'];
2195
2341
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2196
2342
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2197
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2343
+ output?: RstestOutputConfig;
2198
2344
  resolve?: RsbuildConfig['resolve'];
2199
2345
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
2200
2346
  }
@@ -2239,6 +2385,22 @@ declare type RstestContext = {
2239
2385
 
2240
2386
  declare type RstestExpect = ExpectStatic;
2241
2387
 
2388
+ declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
2389
+ distPath?: string | {
2390
+ root?: string;
2391
+ };
2392
+ /**
2393
+ * Whether to bundle third-party dependencies from node_modules.
2394
+ * - `true`: Always bundle all third-party dependencies.
2395
+ * - `false`: Always externalize third-party dependencies.
2396
+ *
2397
+ * When unset, rstest bundles dependencies in browser-like test
2398
+ * environments (jsdom, happy-dom, etc.) and externalizes them in the node
2399
+ * environment. This option is not supported in browser mode.
2400
+ */
2401
+ bundleDependencies?: boolean;
2402
+ };
2403
+
2242
2404
  declare type RstestPoolOptions = {
2243
2405
  /** Pool used to run tests in. */
2244
2406
  type?: RstestPoolType;
@@ -2392,10 +2554,18 @@ declare interface RstestUtilities {
2392
2554
  * Removes module from the mocked registry.
2393
2555
  */
2394
2556
  unmock: (path: string) => void;
2557
+ /**
2558
+ * Removes CommonJS require module from the mocked registry.
2559
+ */
2560
+ unmockRequire: (path: string) => void;
2395
2561
  /**
2396
2562
  * Removes module from the mocked registry, not hoisted.
2397
2563
  */
2398
2564
  doUnmock: (path: string) => void;
2565
+ /**
2566
+ * Removes CommonJS require module from the mocked registry, not hoisted.
2567
+ */
2568
+ doUnmockRequire: (path: string) => void;
2399
2569
  /**
2400
2570
  * Imports a module with all of its properties (including nested properties) mocked.
2401
2571
  */
@@ -2719,6 +2889,12 @@ declare interface SourceMapV3 {
2719
2889
 
2720
2890
  declare type SourcesIndex = number;
2721
2891
 
2892
+ declare function stringify(object: unknown, maxDepth?: number, { maxLength,...options }?: StringifyOptions): string;
2893
+
2894
+ declare interface StringifyOptions extends PrettyFormatOptions {
2895
+ maxLength?: number;
2896
+ }
2897
+
2722
2898
  declare type SuiteContext = {
2723
2899
  filepath: TestPath;
2724
2900
  };
@@ -2760,6 +2936,8 @@ export declare type Test = TestSuite | TestCase;
2760
2936
 
2761
2937
  export declare const test: Rstest['test'];
2762
2938
 
2939
+ declare type Test_2 = (arg0: any) => boolean;
2940
+
2763
2941
  declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
2764
2942
  each: TestEachFn;
2765
2943
  for: TestForFn<ExtraContext>;
@@ -46,11 +46,4 @@ __webpack_require__.m = __webpack_modules__;
46
46
  });
47
47
  };
48
48
  })();
49
- (()=>{
50
- __webpack_require__.nmd = (module)=>{
51
- module.paths = [];
52
- if (!module.children) module.children = [];
53
- return module;
54
- };
55
- })();
56
49
  export { __webpack_require__ };
package/dist/browser.d.ts CHANGED
@@ -2270,7 +2270,7 @@ declare type NormalizedBrowserModeConfig = {
2270
2270
  providerOptions: Record<string, unknown>;
2271
2271
  };
2272
2272
 
2273
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2273
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2274
2274
  pool: RstestPoolOptions;
2275
2275
  testEnvironment: EnvironmentWithOptions;
2276
2276
  coverage: NormalizedCoverageOptions;
@@ -2281,6 +2281,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
2281
2281
  patterns: string[];
2282
2282
  override?: boolean;
2283
2283
  };
2284
+ output: NormalizedOutputConfig;
2284
2285
  };
2285
2286
 
2286
2287
  declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
@@ -2297,13 +2298,20 @@ declare type NormalizedFixture = {
2297
2298
 
2298
2299
  declare type NormalizedFixtures = Record<string, NormalizedFixture>;
2299
2300
 
2301
+ declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
2302
+ distPath: {
2303
+ root: string;
2304
+ };
2305
+ };
2306
+
2300
2307
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
2301
2308
 
2302
2309
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
2303
2310
 
2304
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
2311
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
2305
2312
  setupFiles: string[];
2306
2313
  globalSetup: string[];
2314
+ output?: Omit<NormalizedOutputConfig, 'distPath'>;
2307
2315
  };
2308
2316
 
2309
2317
  declare interface OldPlugin {
@@ -2319,7 +2327,7 @@ export declare const onTestFinished: Rstest_2['onTestFinished'];
2319
2327
 
2320
2328
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2321
2329
 
2322
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2330
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2323
2331
 
2324
2332
  declare interface Options {
2325
2333
  logger: {
@@ -2394,7 +2402,9 @@ declare type Project = {
2394
2402
  configFilePath?: string;
2395
2403
  };
2396
2404
 
2397
- declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
2405
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
2406
+ output?: Omit<RstestOutputConfig, 'distPath'>;
2407
+ };
2398
2408
 
2399
2409
  export declare type ProjectContext = {
2400
2410
  name: string;
@@ -2805,7 +2815,7 @@ declare interface RstestConfig {
2805
2815
  plugins?: RsbuildConfig['plugins'];
2806
2816
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2807
2817
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2808
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2818
+ output?: RstestOutputConfig;
2809
2819
  resolve?: RsbuildConfig['resolve'];
2810
2820
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
2811
2821
  }
@@ -2850,6 +2860,22 @@ declare type RstestContext = {
2850
2860
 
2851
2861
  declare type RstestExpect = ExpectStatic;
2852
2862
 
2863
+ declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
2864
+ distPath?: string | {
2865
+ root?: string;
2866
+ };
2867
+ /**
2868
+ * Whether to bundle third-party dependencies from node_modules.
2869
+ * - `true`: Always bundle all third-party dependencies.
2870
+ * - `false`: Always externalize third-party dependencies.
2871
+ *
2872
+ * When unset, rstest bundles dependencies in browser-like test
2873
+ * environments (jsdom, happy-dom, etc.) and externalizes them in the node
2874
+ * environment. This option is not supported in browser mode.
2875
+ */
2876
+ bundleDependencies?: boolean;
2877
+ };
2878
+
2853
2879
  declare type RstestPoolOptions = {
2854
2880
  /** Pool used to run tests in. */
2855
2881
  type?: RstestPoolType;
@@ -3003,10 +3029,18 @@ declare interface RstestUtilities {
3003
3029
  * Removes module from the mocked registry.
3004
3030
  */
3005
3031
  unmock: (path: string) => void;
3032
+ /**
3033
+ * Removes CommonJS require module from the mocked registry.
3034
+ */
3035
+ unmockRequire: (path: string) => void;
3006
3036
  /**
3007
3037
  * Removes module from the mocked registry, not hoisted.
3008
3038
  */
3009
3039
  doUnmock: (path: string) => void;
3040
+ /**
3041
+ * Removes CommonJS require module from the mocked registry, not hoisted.
3042
+ */
3043
+ doUnmockRequire: (path: string) => void;
3010
3044
  /**
3011
3045
  * Imports a module with all of its properties (including nested properties) mocked.
3012
3046
  */
package/dist/browser.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "node:module";
2
2
  import * as __rspack_external__rsbuild_core_1b356efc from "@rsbuild/core";
3
- export { TEMP_RSTEST_OUTPUT_DIR, getTestEntries, globalApis } from "./4411.js";
3
+ export { TEMP_RSTEST_OUTPUT_DIR, color, globalApis, isDebug, logger, serializableConfig } from "./6830.js";
4
4
  export { afterAll, afterEach, assert, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished, rs, rstest, test } from "./5040.js";
5
- export { color, isDebug, logger, serializableConfig } from "./6830.js";
6
5
  export { createRstestRuntime } from "./1949.js";
7
6
  export { getSetupFiles } from "./255.js";
7
+ export { getTestEntries } from "./4411.js";
8
8
  export { loadCoverageProvider } from "./7704.js";
9
9
  export { setRealTimers } from "./7552.js";
10
10
  export { __rspack_external__rsbuild_core_1b356efc as rsbuild };
@@ -72,7 +72,7 @@ const runGlobalSetup = async (data)=>{
72
72
  return {
73
73
  success: false,
74
74
  hasTeardown: false,
75
- errors: formatTestError(error)
75
+ errors: await formatTestError(error)
76
76
  };
77
77
  }
78
78
  };
package/dist/index.d.ts CHANGED
@@ -2286,7 +2286,7 @@ declare type NormalizedBrowserModeConfig = {
2286
2286
  providerOptions: Record<string, unknown>;
2287
2287
  };
2288
2288
 
2289
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2289
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2290
2290
  pool: RstestPoolOptions;
2291
2291
  testEnvironment: EnvironmentWithOptions;
2292
2292
  coverage: NormalizedCoverageOptions;
@@ -2297,6 +2297,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
2297
2297
  patterns: string[];
2298
2298
  override?: boolean;
2299
2299
  };
2300
+ output: NormalizedOutputConfig;
2300
2301
  };
2301
2302
 
2302
2303
  export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
@@ -2304,13 +2305,20 @@ export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, '
2304
2305
  include?: string[];
2305
2306
  };
2306
2307
 
2308
+ declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
2309
+ distPath: {
2310
+ root: string;
2311
+ };
2312
+ };
2313
+
2307
2314
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
2308
2315
 
2309
2316
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
2310
2317
 
2311
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
2318
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
2312
2319
  setupFiles: string[];
2313
2320
  globalSetup: string[];
2321
+ output?: Omit<NormalizedOutputConfig, 'distPath'>;
2314
2322
  };
2315
2323
 
2316
2324
  declare interface OldPlugin {
@@ -2326,7 +2334,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
2326
2334
 
2327
2335
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2328
2336
 
2329
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2337
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2330
2338
 
2331
2339
  declare interface Options {
2332
2340
  logger: {
@@ -2393,7 +2401,9 @@ declare type Project = {
2393
2401
  configFilePath?: string;
2394
2402
  };
2395
2403
 
2396
- export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
2404
+ export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
2405
+ output?: Omit<RstestOutputConfig, 'distPath'>;
2406
+ };
2397
2407
 
2398
2408
  declare type ProjectConfigAsyncFn = () => Promise<ProjectConfig | NestedProjectConfig>;
2399
2409
 
@@ -2786,7 +2796,7 @@ export declare interface RstestConfig {
2786
2796
  plugins?: RsbuildConfig['plugins'];
2787
2797
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2788
2798
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2789
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2799
+ output?: RstestOutputConfig;
2790
2800
  resolve?: RsbuildConfig['resolve'];
2791
2801
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
2792
2802
  }
@@ -2845,6 +2855,22 @@ declare type RstestInstance = {
2845
2855
  }) => Promise<void>;
2846
2856
  };
2847
2857
 
2858
+ declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
2859
+ distPath?: string | {
2860
+ root?: string;
2861
+ };
2862
+ /**
2863
+ * Whether to bundle third-party dependencies from node_modules.
2864
+ * - `true`: Always bundle all third-party dependencies.
2865
+ * - `false`: Always externalize third-party dependencies.
2866
+ *
2867
+ * When unset, rstest bundles dependencies in browser-like test
2868
+ * environments (jsdom, happy-dom, etc.) and externalizes them in the node
2869
+ * environment. This option is not supported in browser mode.
2870
+ */
2871
+ bundleDependencies?: boolean;
2872
+ };
2873
+
2848
2874
  declare type RstestPoolOptions = {
2849
2875
  /** Pool used to run tests in. */
2850
2876
  type?: RstestPoolType;
@@ -2998,10 +3024,18 @@ export declare interface RstestUtilities {
2998
3024
  * Removes module from the mocked registry.
2999
3025
  */
3000
3026
  unmock: (path: string) => void;
3027
+ /**
3028
+ * Removes CommonJS require module from the mocked registry.
3029
+ */
3030
+ unmockRequire: (path: string) => void;
3001
3031
  /**
3002
3032
  * Removes module from the mocked registry, not hoisted.
3003
3033
  */
3004
3034
  doUnmock: (path: string) => void;
3035
+ /**
3036
+ * Removes CommonJS require module from the mocked registry, not hoisted.
3037
+ */
3038
+ doUnmockRequire: (path: string) => void;
3005
3039
  /**
3006
3040
  * Imports a module with all of its properties (including nested properties) mocked.
3007
3041
  */
@@ -28,6 +28,8 @@ __webpack_require__.rstest_unmock = (id)=>{
28
28
  delete __webpack_module_cache__[id];
29
29
  };
30
30
  __webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
31
+ __webpack_require__.rstest_unmock_require = __webpack_require__.rstest_unmock;
32
+ __webpack_require__.rstest_do_unmock_require = __webpack_require__.rstest_do_unmock;
31
33
  __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
32
34
  if (hasOwn(__webpack_require__.rstest_original_modules, id)) return __webpack_require__.rstest_original_modules[id];
33
35
  if (hasOwn(__webpack_require__.rstest_original_module_factories, id)) {