@rstest/core 0.9.4 → 0.9.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 (52) hide show
  1. package/LICENSE.md +54 -202
  2. package/dist/0~8843.js +32 -14
  3. package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
  4. package/dist/0~@clack/prompts.js +1044 -0
  5. package/dist/0~browserLoader.js +1 -1
  6. package/dist/0~browser~1.js +19 -19
  7. package/dist/0~checkThresholds.js +2 -2
  8. package/dist/0~chokidar.js +43 -42
  9. package/dist/0~console.js +1 -1
  10. package/dist/0~fake-timers.js +1586 -0
  11. package/dist/0~generate.js +5 -5
  12. package/dist/0~happyDom.js +1 -1
  13. package/dist/0~jsdom.js +1 -1
  14. package/dist/0~listTests.js +3 -3
  15. package/dist/0~loadModule.js +1 -1
  16. package/dist/0~magic-string.es.js +1 -181
  17. package/dist/0~restart.js +1 -1
  18. package/dist/0~runTests.js +11 -4
  19. package/dist/0~snapshot.js +2140 -0
  20. package/dist/0~snapshot.js.LICENSE.txt +7 -0
  21. package/dist/0~utils.js +1 -1
  22. package/dist/1255.js +11 -11
  23. package/dist/1949.js +2919 -9808
  24. package/dist/1949.js.LICENSE.txt +1 -49
  25. package/dist/3145.js +415 -40
  26. package/dist/4411.js +245 -60
  27. package/dist/6830.js +62 -10
  28. package/dist/6887.js +15 -0
  29. package/dist/7552.js +22 -4918
  30. package/dist/9743.js +1982 -0
  31. package/dist/9784.js +1343 -0
  32. package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
  33. package/dist/browser-runtime/2~fake-timers.js +1760 -0
  34. package/dist/browser-runtime/2~magic-string.es.js +3 -189
  35. package/dist/browser-runtime/2~snapshot.js +2138 -0
  36. package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
  37. package/dist/browser-runtime/723.js +1818 -10300
  38. package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
  39. package/dist/browser-runtime/index.d.ts +205 -16
  40. package/dist/browser.d.ts +55 -10
  41. package/dist/browser.js +2 -2
  42. package/dist/globalSetupWorker.js +2 -2
  43. package/dist/index.d.ts +78 -16
  44. package/dist/index.js +1 -1
  45. package/dist/mockRuntimeCode.js +2 -0
  46. package/dist/worker.d.ts +47 -10
  47. package/dist/worker.js +12 -10
  48. package/package.json +27 -28
  49. package/dist/0~dist.js +0 -1014
  50. package/dist/4899.js +0 -11
  51. package/dist/browser-runtime/rslib-runtime.js +0 -56
  52. /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
@@ -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
  /**
@@ -362,7 +356,7 @@ declare type BrowserViewport = {
362
356
  height: number;
363
357
  } | DevicePreset;
364
358
 
365
- declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
359
+ declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'json' | 'blob';
366
360
 
367
361
  declare type BuiltinReporterOptions = {
368
362
  default: DefaultReporterOptions;
@@ -370,6 +364,7 @@ declare type BuiltinReporterOptions = {
370
364
  md: MdReporterOptions;
371
365
  'github-actions': Record<string, unknown>;
372
366
  junit: Record<string, unknown>;
367
+ json: JsonReporterOptions;
373
368
  blob: BlobReporterOptions;
374
369
  };
375
370
 
@@ -379,6 +374,58 @@ declare interface CloverOptions extends FileOptions, ProjectOptions {}
379
374
 
380
375
  declare interface CoberturaOptions extends FileOptions, ProjectOptions {}
381
376
 
377
+ /**
378
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
379
+ *
380
+ * This source code is licensed under the MIT license found in the
381
+ * LICENSE file in the root directory of this source tree.
382
+ */
383
+ declare interface Colors {
384
+ comment: {
385
+ close: string
386
+ open: string
387
+ };
388
+ content: {
389
+ close: string
390
+ open: string
391
+ };
392
+ prop: {
393
+ close: string
394
+ open: string
395
+ };
396
+ tag: {
397
+ close: string
398
+ open: string
399
+ };
400
+ value: {
401
+ close: string
402
+ open: string
403
+ };
404
+ }
405
+
406
+ declare type CompareKeys = ((a: string, b: string) => number) | null | undefined;
407
+
408
+ declare interface Config {
409
+ callToJSON: boolean;
410
+ compareKeys: CompareKeys;
411
+ colors: Colors;
412
+ escapeRegex: boolean;
413
+ escapeString: boolean;
414
+ indent: string;
415
+ maxDepth: number;
416
+ maxWidth: number;
417
+ min: boolean;
418
+ plugins: Plugins;
419
+ printBasicPrototype: boolean;
420
+ printFunctionName: boolean;
421
+ spacingInner: string;
422
+ spacingOuter: string;
423
+ }
424
+
425
+ declare interface Constructable {
426
+ new (...args: any[]): any;
427
+ }
428
+
382
429
  declare type Constructor<T = any> = new (...args: any[]) => T;
383
430
 
384
431
  /**
@@ -476,11 +523,14 @@ declare type CoverageOptions = {
476
523
  * This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
477
524
  *
478
525
  * @default ['**\/node_modules/**',
479
- * '**\/dist/**',
480
526
  * '**\/test/**',
481
527
  * '**\/__tests__/**',
482
- * '**\/*.{test,spec}.?(c|m)[jt]s?(x)',
483
- * '**\/__mocks__/**'
528
+ * '**\/__mocks__/**',
529
+ * '**\/*.d.ts',
530
+ * '**\/*.{test,spec}.[jt]s',
531
+ * '**\/*.{test,spec}.[cm][jt]s',
532
+ * '**\/*.{test,spec}.[jt]sx',
533
+ * '**\/*.{test,spec}.[cm][jt]sx'
484
534
  * ]
485
535
  */
486
536
  exclude?: string[];
@@ -684,6 +734,49 @@ declare interface DescribeForFn {
684
734
  */
685
735
  declare type DevicePreset = 'iPhoneSE' | 'iPhoneXR' | 'iPhone12Pro' | 'iPhone14ProMax' | 'Pixel7' | 'SamsungGalaxyS8Plus' | 'SamsungGalaxyS20Ultra' | 'iPadMini' | 'iPadAir' | 'iPadPro' | 'SurfacePro7' | 'SurfaceDuo' | 'GalaxyZFold5' | 'AsusZenbookFold' | 'SamsungGalaxyA51A71' | 'NestHub' | 'NestHubMax';
686
736
 
737
+ /**
738
+ * @param a Expected value
739
+ * @param b Received value
740
+ * @param options Diff options
741
+ * @returns {string | null} a string diff
742
+ */
743
+ declare function diff(a: any, b: any, options?: DiffOptions): string | undefined;
744
+
745
+ declare interface DiffOptions {
746
+ aAnnotation?: string;
747
+ aColor?: DiffOptionsColor;
748
+ aIndicator?: string;
749
+ bAnnotation?: string;
750
+ bColor?: DiffOptionsColor;
751
+ bIndicator?: string;
752
+ changeColor?: DiffOptionsColor;
753
+ changeLineTrailingSpaceColor?: DiffOptionsColor;
754
+ commonColor?: DiffOptionsColor;
755
+ commonIndicator?: string;
756
+ commonLineTrailingSpaceColor?: DiffOptionsColor;
757
+ contextLines?: number;
758
+ emptyFirstOrLastLinePlaceholder?: string;
759
+ expand?: boolean;
760
+ includeChangeCounts?: boolean;
761
+ omitAnnotationLines?: boolean;
762
+ patchColor?: DiffOptionsColor;
763
+ printBasicPrototype?: boolean;
764
+ maxDepth?: number;
765
+ compareKeys?: CompareKeys;
766
+ truncateThreshold?: number;
767
+ truncateAnnotation?: string;
768
+ truncateAnnotationColor?: DiffOptionsColor;
769
+ }
770
+
771
+ /**
772
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
773
+ *
774
+ * This source code is licensed under the MIT license found in the
775
+ * LICENSE file in the root directory of this source tree.
776
+ */
777
+
778
+ declare type DiffOptionsColor = (arg: string) => string;
779
+
687
780
  /** The test file output path */
688
781
  declare type DistPath = string;
689
782
 
@@ -929,6 +1022,8 @@ declare interface HtmlSpaOptions extends HtmlOptions {
929
1022
  metricsToShow: Array<"lines" | "branches" | "functions" | "statements">;
930
1023
  }
931
1024
 
1025
+ declare type Indent = (arg0: string) => string;
1026
+
932
1027
  /**
933
1028
  * A list of glob patterns or files that match your test projects.
934
1029
  *
@@ -1341,6 +1436,13 @@ declare interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomM
1341
1436
 
1342
1437
  declare type JsonOptions = FileOptions;
1343
1438
 
1439
+ declare type JsonReporterOptions = {
1440
+ /**
1441
+ * Write report JSON to a file instead of stdout.
1442
+ */
1443
+ outputPath?: string;
1444
+ };
1445
+
1344
1446
  declare type JsonSummaryOptions = FileOptions;
1345
1447
 
1346
1448
  declare interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
@@ -1726,6 +1828,11 @@ declare interface MockSettledResultRejected {
1726
1828
 
1727
1829
  declare type NamesIndex = number;
1728
1830
 
1831
+ declare interface NewPlugin {
1832
+ serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
1833
+ test: Test_2;
1834
+ }
1835
+
1729
1836
  declare interface Node_2 {
1730
1837
  isRoot(): boolean;
1731
1838
  visit(visitor: Visitor, state: any): void;
@@ -1742,7 +1849,7 @@ declare type NormalizedBrowserModeConfig = {
1742
1849
  providerOptions: Record<string, unknown>;
1743
1850
  };
1744
1851
 
1745
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
1852
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
1746
1853
  pool: RstestPoolOptions;
1747
1854
  testEnvironment: EnvironmentWithOptions;
1748
1855
  coverage: NormalizedCoverageOptions;
@@ -1753,6 +1860,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
1753
1860
  patterns: string[];
1754
1861
  override?: boolean;
1755
1862
  };
1863
+ output: NormalizedOutputConfig;
1756
1864
  };
1757
1865
 
1758
1866
  declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
@@ -1769,13 +1877,25 @@ declare type NormalizedFixture = {
1769
1877
 
1770
1878
  declare type NormalizedFixtures = Record<string, NormalizedFixture>;
1771
1879
 
1880
+ declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
1881
+ distPath: {
1882
+ root: string;
1883
+ };
1884
+ };
1885
+
1772
1886
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
1773
1887
 
1774
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
1888
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
1775
1889
  setupFiles: string[];
1776
1890
  globalSetup: string[];
1891
+ output?: Omit<NormalizedOutputConfig, 'distPath'>;
1777
1892
  };
1778
1893
 
1894
+ declare interface OldPlugin {
1895
+ print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
1896
+ test: Test_2;
1897
+ }
1898
+
1779
1899
  export declare const onTestFailed: Rstest['onTestFailed'];
1780
1900
 
1781
1901
  declare type OnTestFailedHandler = (ctx: TestContext) => MaybePromise<void>;
@@ -1784,7 +1904,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
1784
1904
 
1785
1905
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
1786
1906
 
1787
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
1907
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
1788
1908
 
1789
1909
  declare interface Options {
1790
1910
  logger: {
@@ -1796,6 +1916,8 @@ declare interface Options {
1796
1916
  getWindow: () => string[];
1797
1917
  }
1798
1918
 
1919
+ declare type OptionsReceived = PrettyFormatOptions;
1920
+
1799
1921
  declare interface ParsedStack {
1800
1922
  method: string;
1801
1923
  file: string;
@@ -1803,6 +1925,37 @@ declare interface ParsedStack {
1803
1925
  column: number;
1804
1926
  }
1805
1927
 
1928
+ declare type Plugin_2 = NewPlugin | OldPlugin;
1929
+
1930
+ declare interface PluginOptions {
1931
+ edgeSpacing: string;
1932
+ min: boolean;
1933
+ spacing: string;
1934
+ }
1935
+
1936
+ declare type Plugins = Array<Plugin_2>;
1937
+
1938
+ declare interface PrettyFormatOptions {
1939
+ callToJSON?: boolean;
1940
+ escapeRegex?: boolean;
1941
+ escapeString?: boolean;
1942
+ highlight?: boolean;
1943
+ indent?: number;
1944
+ maxDepth?: number;
1945
+ maxWidth?: number;
1946
+ min?: boolean;
1947
+ printBasicPrototype?: boolean;
1948
+ printFunctionName?: boolean;
1949
+ compareKeys?: CompareKeys;
1950
+ plugins?: Plugins;
1951
+ }
1952
+
1953
+ declare type Print = (arg0: unknown) => string;
1954
+
1955
+ declare function printDiffOrStringify(received: unknown, expected: unknown, options?: DiffOptions): string | undefined;
1956
+
1957
+ declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
1958
+
1806
1959
  declare function printExpected(value: unknown): string;
1807
1960
 
1808
1961
  declare function printReceived(object: unknown): string;
@@ -1811,7 +1964,9 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
1811
1964
 
1812
1965
  declare type Procedure = (...args: any[]) => any;
1813
1966
 
1814
- declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
1967
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
1968
+ output?: Omit<RstestOutputConfig, 'distPath'>;
1969
+ };
1815
1970
 
1816
1971
  declare type ProjectContext = {
1817
1972
  name: string;
@@ -1861,6 +2016,8 @@ declare interface RawSnapshotInfo {
1861
2016
  content?: string;
1862
2017
  }
1863
2018
 
2019
+ declare type Refs = Array<unknown>;
2020
+
1864
2021
  declare class ReportBase {
1865
2022
  constructor(options?: Partial<ReportBaseOptions>);
1866
2023
  execute(context: Context): void;
@@ -2192,9 +2349,9 @@ declare interface RstestConfig {
2192
2349
  */
2193
2350
  includeTaskLocation?: boolean;
2194
2351
  plugins?: RsbuildConfig['plugins'];
2195
- source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2352
+ source?: Pick<NonNullable<RsbuildConfig['source']>, 'assetsInclude' | 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude' | 'transformImport' | 'assetsInclude'>;
2196
2353
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2197
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2354
+ output?: RstestOutputConfig;
2198
2355
  resolve?: RsbuildConfig['resolve'];
2199
2356
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
2200
2357
  }
@@ -2239,6 +2396,22 @@ declare type RstestContext = {
2239
2396
 
2240
2397
  declare type RstestExpect = ExpectStatic;
2241
2398
 
2399
+ declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
2400
+ distPath?: string | {
2401
+ root?: string;
2402
+ };
2403
+ /**
2404
+ * Whether to bundle third-party dependencies from node_modules.
2405
+ * - `true`: Always bundle all third-party dependencies.
2406
+ * - `false`: Always externalize third-party dependencies.
2407
+ *
2408
+ * When unset, rstest bundles dependencies in browser-like test
2409
+ * environments (jsdom, happy-dom, etc.) and externalizes them in the node
2410
+ * environment. This option is not supported in browser mode.
2411
+ */
2412
+ bundleDependencies?: boolean;
2413
+ };
2414
+
2242
2415
  declare type RstestPoolOptions = {
2243
2416
  /** Pool used to run tests in. */
2244
2417
  type?: RstestPoolType;
@@ -2392,10 +2565,18 @@ declare interface RstestUtilities {
2392
2565
  * Removes module from the mocked registry.
2393
2566
  */
2394
2567
  unmock: (path: string) => void;
2568
+ /**
2569
+ * Removes CommonJS require module from the mocked registry.
2570
+ */
2571
+ unmockRequire: (path: string) => void;
2395
2572
  /**
2396
2573
  * Removes module from the mocked registry, not hoisted.
2397
2574
  */
2398
2575
  doUnmock: (path: string) => void;
2576
+ /**
2577
+ * Removes CommonJS require module from the mocked registry, not hoisted.
2578
+ */
2579
+ doUnmockRequire: (path: string) => void;
2399
2580
  /**
2400
2581
  * Imports a module with all of its properties (including nested properties) mocked.
2401
2582
  */
@@ -2719,6 +2900,12 @@ declare interface SourceMapV3 {
2719
2900
 
2720
2901
  declare type SourcesIndex = number;
2721
2902
 
2903
+ declare function stringify(object: unknown, maxDepth?: number, { maxLength,...options }?: StringifyOptions): string;
2904
+
2905
+ declare interface StringifyOptions extends PrettyFormatOptions {
2906
+ maxLength?: number;
2907
+ }
2908
+
2722
2909
  declare type SuiteContext = {
2723
2910
  filepath: TestPath;
2724
2911
  };
@@ -2760,6 +2947,8 @@ export declare type Test = TestSuite | TestCase;
2760
2947
 
2761
2948
  export declare const test: Rstest['test'];
2762
2949
 
2950
+ declare type Test_2 = (arg0: any) => boolean;
2951
+
2763
2952
  declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
2764
2953
  each: TestEachFn;
2765
2954
  for: TestForFn<ExtraContext>;
package/dist/browser.d.ts CHANGED
@@ -408,7 +408,7 @@ declare type BrowserViewport = {
408
408
  height: number;
409
409
  } | DevicePreset;
410
410
 
411
- declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
411
+ declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'json' | 'blob';
412
412
 
413
413
  declare type BuiltinReporterOptions = {
414
414
  default: DefaultReporterOptions;
@@ -416,6 +416,7 @@ declare type BuiltinReporterOptions = {
416
416
  md: MdReporterOptions;
417
417
  'github-actions': Record<string, unknown>;
418
418
  junit: Record<string, unknown>;
419
+ json: JsonReporterOptions;
419
420
  blob: BlobReporterOptions;
420
421
  };
421
422
 
@@ -591,11 +592,14 @@ declare type CoverageOptions = {
591
592
  * This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
592
593
  *
593
594
  * @default ['**\/node_modules/**',
594
- * '**\/dist/**',
595
595
  * '**\/test/**',
596
596
  * '**\/__tests__/**',
597
- * '**\/*.{test,spec}.?(c|m)[jt]s?(x)',
598
- * '**\/__mocks__/**'
597
+ * '**\/__mocks__/**',
598
+ * '**\/*.d.ts',
599
+ * '**\/*.{test,spec}.[jt]s',
600
+ * '**\/*.{test,spec}.[cm][jt]s',
601
+ * '**\/*.{test,spec}.[jt]sx',
602
+ * '**\/*.{test,spec}.[cm][jt]sx'
599
603
  * ]
600
604
  */
601
605
  exclude?: string[];
@@ -1551,6 +1555,13 @@ declare interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomM
1551
1555
 
1552
1556
  declare type JsonOptions = FileOptions;
1553
1557
 
1558
+ declare type JsonReporterOptions = {
1559
+ /**
1560
+ * Write report JSON to a file instead of stdout.
1561
+ */
1562
+ outputPath?: string;
1563
+ };
1564
+
1554
1565
  declare type JsonSummaryOptions = FileOptions;
1555
1566
 
1556
1567
  declare interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
@@ -2270,7 +2281,7 @@ declare type NormalizedBrowserModeConfig = {
2270
2281
  providerOptions: Record<string, unknown>;
2271
2282
  };
2272
2283
 
2273
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2284
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2274
2285
  pool: RstestPoolOptions;
2275
2286
  testEnvironment: EnvironmentWithOptions;
2276
2287
  coverage: NormalizedCoverageOptions;
@@ -2281,6 +2292,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
2281
2292
  patterns: string[];
2282
2293
  override?: boolean;
2283
2294
  };
2295
+ output: NormalizedOutputConfig;
2284
2296
  };
2285
2297
 
2286
2298
  declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
@@ -2297,13 +2309,20 @@ declare type NormalizedFixture = {
2297
2309
 
2298
2310
  declare type NormalizedFixtures = Record<string, NormalizedFixture>;
2299
2311
 
2312
+ declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
2313
+ distPath: {
2314
+ root: string;
2315
+ };
2316
+ };
2317
+
2300
2318
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
2301
2319
 
2302
2320
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
2303
2321
 
2304
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
2322
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
2305
2323
  setupFiles: string[];
2306
2324
  globalSetup: string[];
2325
+ output?: Omit<NormalizedOutputConfig, 'distPath'>;
2307
2326
  };
2308
2327
 
2309
2328
  declare interface OldPlugin {
@@ -2319,7 +2338,7 @@ export declare const onTestFinished: Rstest_2['onTestFinished'];
2319
2338
 
2320
2339
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2321
2340
 
2322
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2341
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2323
2342
 
2324
2343
  declare interface Options {
2325
2344
  logger: {
@@ -2394,7 +2413,9 @@ declare type Project = {
2394
2413
  configFilePath?: string;
2395
2414
  };
2396
2415
 
2397
- declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
2416
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
2417
+ output?: Omit<RstestOutputConfig, 'distPath'>;
2418
+ };
2398
2419
 
2399
2420
  export declare type ProjectContext = {
2400
2421
  name: string;
@@ -2803,9 +2824,9 @@ declare interface RstestConfig {
2803
2824
  */
2804
2825
  includeTaskLocation?: boolean;
2805
2826
  plugins?: RsbuildConfig['plugins'];
2806
- source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2827
+ source?: Pick<NonNullable<RsbuildConfig['source']>, 'assetsInclude' | 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude' | 'transformImport' | 'assetsInclude'>;
2807
2828
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2808
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2829
+ output?: RstestOutputConfig;
2809
2830
  resolve?: RsbuildConfig['resolve'];
2810
2831
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
2811
2832
  }
@@ -2850,6 +2871,22 @@ declare type RstestContext = {
2850
2871
 
2851
2872
  declare type RstestExpect = ExpectStatic;
2852
2873
 
2874
+ declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
2875
+ distPath?: string | {
2876
+ root?: string;
2877
+ };
2878
+ /**
2879
+ * Whether to bundle third-party dependencies from node_modules.
2880
+ * - `true`: Always bundle all third-party dependencies.
2881
+ * - `false`: Always externalize third-party dependencies.
2882
+ *
2883
+ * When unset, rstest bundles dependencies in browser-like test
2884
+ * environments (jsdom, happy-dom, etc.) and externalizes them in the node
2885
+ * environment. This option is not supported in browser mode.
2886
+ */
2887
+ bundleDependencies?: boolean;
2888
+ };
2889
+
2853
2890
  declare type RstestPoolOptions = {
2854
2891
  /** Pool used to run tests in. */
2855
2892
  type?: RstestPoolType;
@@ -3003,10 +3040,18 @@ declare interface RstestUtilities {
3003
3040
  * Removes module from the mocked registry.
3004
3041
  */
3005
3042
  unmock: (path: string) => void;
3043
+ /**
3044
+ * Removes CommonJS require module from the mocked registry.
3045
+ */
3046
+ unmockRequire: (path: string) => void;
3006
3047
  /**
3007
3048
  * Removes module from the mocked registry, not hoisted.
3008
3049
  */
3009
3050
  doUnmock: (path: string) => void;
3051
+ /**
3052
+ * Removes CommonJS require module from the mocked registry, not hoisted.
3053
+ */
3054
+ doUnmockRequire: (path: string) => void;
3010
3055
  /**
3011
3056
  * Imports a module with all of its properties (including nested properties) mocked.
3012
3057
  */
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 };
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import { __webpack_require__ } from "./0~rslib-runtime.js";
3
3
  import "./1255.js";
4
4
  import { color as logger_color } from "./6830.js";
5
5
  import { formatTestError } from "./7552.js";
@@ -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
  };