@rstest/core 0.7.9 → 0.8.1

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/index.d.ts CHANGED
@@ -275,20 +275,14 @@ declare type BrowserModeConfig = {
275
275
  * Browser provider to use for running tests.
276
276
  *
277
277
  * Currently only 'playwright' is supported.
278
- *
279
- * @default 'playwright'
280
278
  */
281
- provider?: 'playwright';
279
+ provider: 'playwright';
282
280
  /**
283
281
  * Which browser to use for testing.
284
282
  *
285
- * - `chromium` - Google Chrome, Microsoft Edge
286
- * - `firefox` - Mozilla Firefox
287
- * - `webkit` - Safari
288
- *
289
283
  * @default 'chromium'
290
284
  */
291
- browser?: 'chromium' | 'firefox' | 'webkit';
285
+ browser?: BrowserName;
292
286
  /**
293
287
  * Run browser in headless mode.
294
288
  *
@@ -301,12 +295,28 @@ declare type BrowserModeConfig = {
301
295
  * If not specified, a random available port will be used.
302
296
  */
303
297
  port?: number;
298
+ /**
299
+ * Whether to exit if the specified port is already in use.
300
+ *
301
+ * @default false
302
+ */
303
+ strictPort?: boolean;
304
304
  };
305
305
 
306
+ /**
307
+ * Supported browser types for browser mode testing.
308
+ *
309
+ * - `chromium` - Google Chrome, Microsoft Edge
310
+ * - `firefox` - Mozilla Firefox
311
+ * - `webkit` - Safari
312
+ */
313
+ declare type BrowserName = 'chromium' | 'firefox' | 'webkit';
314
+
306
315
  declare type BuiltInReporterNames = keyof typeof reportersMap;
307
316
 
308
317
  declare type BuiltinReporterOptions = {
309
318
  default: DefaultReporterOptions;
319
+ verbose: VerboseReporterOptions;
310
320
  };
311
321
 
312
322
  declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
@@ -349,7 +359,29 @@ declare type CommonOptions = {
349
359
  config?: string;
350
360
  configLoader?: LoadConfigOptions['loader'];
351
361
  globals?: boolean;
352
- browser?: boolean;
362
+ /**
363
+ * Pool options.
364
+ * - `string`: shorthand for `{ type: string }` (from `--pool` flag)
365
+ * - `object`: detailed pool config (from `--pool.*` options)
366
+ */
367
+ pool?: string | {
368
+ type?: string;
369
+ maxWorkers?: string | number;
370
+ minWorkers?: string | number;
371
+ execArgv?: string[] | string;
372
+ };
373
+ /**
374
+ * Browser mode options.
375
+ * - `boolean`: shorthand for `{ enabled: boolean }` (from `--browser` flag)
376
+ * - `object`: detailed browser config (from `--browser.*` options)
377
+ */
378
+ browser?: boolean | {
379
+ enabled?: boolean;
380
+ name?: BrowserName;
381
+ headless?: boolean;
382
+ port?: number;
383
+ strictPort?: boolean;
384
+ };
353
385
  isolate?: boolean;
354
386
  include?: string[];
355
387
  exclude?: string[];
@@ -374,6 +406,7 @@ declare type CommonOptions = {
374
406
  maxConcurrency?: number;
375
407
  slowTestThreshold?: number;
376
408
  hideSkippedTests?: boolean;
409
+ hideSkippedTestFiles?: boolean;
377
410
  bail?: number | boolean;
378
411
  };
379
412
 
@@ -400,6 +433,8 @@ declare interface Constructable {
400
433
  new (...args: any[]): any;
401
434
  }
402
435
 
436
+ declare type Constructor<T = any> = new (...args: any[]) => T;
437
+
403
438
  /**
404
439
  * Base class for writing content
405
440
  */
@@ -689,6 +724,12 @@ declare class DefaultReporter implements Reporter {
689
724
  options: DefaultReporterOptions;
690
725
  testState: RstestTestState;
691
726
  });
727
+ /**
728
+ * Lazily create StatusRenderer on first test file start.
729
+ * This avoids intercepting stdout/stderr before tests actually begin,
730
+ * ensuring early errors (like missing Playwright browsers) remain visible.
731
+ */
732
+ private ensureStatusRenderer;
692
733
  onTestFileStart(): void;
693
734
  onTestFileResult(test: TestFileResult): void;
694
735
  onTestCaseResult(): void;
@@ -716,6 +757,11 @@ declare type DefaultReporterOptions = {
716
757
  * @default process.stdout/process.stderr
717
758
  */
718
759
  logger?: Options['logger'];
760
+ /**
761
+ * prints out project name in test file title
762
+ * show project name by default when running multiple projects
763
+ */
764
+ showProjectName?: boolean;
719
765
  };
720
766
 
721
767
  /**
@@ -867,9 +913,9 @@ declare interface ExpectStatic_2 extends Chai.ExpectStatic, Matchers, Asymmetric
867
913
  not: AsymmetricMatchersContaining;
868
914
  }
869
915
 
870
- export declare type ExtendConfig = Omit<RstestConfig, 'projects'>;
916
+ export declare type ExtendConfig = Omit<LooseRstestConfig, 'projects'>;
871
917
 
872
- export declare type ExtendConfigFn = (userConfig: Readonly<RstestConfig>) => MaybePromise<ExtendConfig>;
918
+ export declare type ExtendConfigFn = (userConfig: Readonly<LooseRstestConfig>) => MaybePromise<ExtendConfig>;
873
919
 
874
920
  /**
875
921
  * Names of clock methods that may be faked by install.
@@ -1563,6 +1609,10 @@ declare interface Location_3 {
1563
1609
  column: number;
1564
1610
  }
1565
1611
 
1612
+ declare type LooseRstestConfig = Omit<RstestConfig, 'reporters'> & {
1613
+ reporters?: any;
1614
+ };
1615
+
1566
1616
  declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
1567
1617
 
1568
1618
  declare interface MatcherHintOptions {
@@ -1613,12 +1663,22 @@ declare interface MatcherState_2 extends MatcherState {
1613
1663
  snapshotState: SnapshotState;
1614
1664
  }
1615
1665
 
1666
+ declare type MaybeMockedDeep<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
1667
+
1668
+ declare type MaybePartiallyMocked<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
1669
+
1670
+ declare type MaybePartiallyMockedDeep<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
1671
+
1616
1672
  declare type MaybePromise<T> = T | Promise<T>;
1617
1673
 
1618
1674
  export declare const mergeProjectConfig: (...configs: ProjectConfig[]) => ProjectConfig;
1619
1675
 
1620
1676
  export declare const mergeRstestConfig: (...configs: RstestConfig[]) => RstestConfig;
1621
1677
 
1678
+ declare type Methods<T> = {
1679
+ [K in keyof T]: T[K] extends MockProcedure ? K : never;
1680
+ }[keyof T];
1681
+
1622
1682
  export declare interface Mock<T extends FunctionLike = FunctionLike> extends MockInstance_2<T> {
1623
1683
  new (...args: Parameters<T>): ReturnType<T>;
1624
1684
  (...args: Parameters<T>): ReturnType<T>;
@@ -1767,6 +1827,31 @@ declare type MockContext_2<T extends FunctionLike = FunctionLike> = {
1767
1827
  settledResults: MockSettledResult_2<Awaited<ReturnType<T>>>[];
1768
1828
  };
1769
1829
 
1830
+ export declare type Mocked<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
1831
+
1832
+ declare type MockedClass<T extends Constructor> = Mock<(...args: ConstructorParameters<T>) => InstanceType<T>> & {
1833
+ new (...args: ConstructorParameters<T>): InstanceType<T>;
1834
+ prototype: InstanceType<T>;
1835
+ };
1836
+
1837
+ declare type MockedFunction<T extends MockProcedure> = Mock<T> & {
1838
+ [K in keyof T]: T[K];
1839
+ };
1840
+
1841
+ declare type MockedFunctionDeep<T extends MockProcedure> = Mock<T> & MockedObjectDeep<T>;
1842
+
1843
+ declare type MockedObject<T> = {
1844
+ [K in Methods<T>]: T[K] extends MockProcedure ? MockedFunction<T[K]> : T[K];
1845
+ } & {
1846
+ [K in Properties<T>]: T[K];
1847
+ };
1848
+
1849
+ declare type MockedObjectDeep<T> = {
1850
+ [K in Methods<T>]: T[K] extends MockProcedure ? MockedFunctionDeep<T[K]> : T[K];
1851
+ } & {
1852
+ [K in Properties<T>]: MaybeMockedDeep<T[K]>;
1853
+ };
1854
+
1770
1855
  declare type MockFactory<T = unknown> = () => MaybePromise<Partial<T>>;
1771
1856
 
1772
1857
  declare type MockFn = <T extends FunctionLike = FunctionLike>(fn?: T) => Mock<T>;
@@ -1993,6 +2078,37 @@ declare interface MockInstance_2<T extends FunctionLike = FunctionLike> {
1993
2078
  mockRejectedValueOnce(error: unknown): this;
1994
2079
  }
1995
2080
 
2081
+ /**
2082
+ * Options for rs.mock module mocking.
2083
+ * Supports `{ spy: true }` or `{ mock: true }`.
2084
+ */
2085
+ declare type MockModuleOptions = {
2086
+ /**
2087
+ * If `true`, the module will be auto-mocked but the original implementations
2088
+ * will be preserved - all exports will be wrapped in spy functions that track calls.
2089
+ */
2090
+ spy: true;
2091
+ } | {
2092
+ /**
2093
+ * If `true`, the module will be auto-mocked with all exports replaced by mock functions.
2094
+ * Original implementations will NOT be preserved.
2095
+ */
2096
+ mock: true;
2097
+ };
2098
+
2099
+ /**
2100
+ * Options for mockObject
2101
+ */
2102
+ declare interface MockOptions {
2103
+ /**
2104
+ * If `true`, the original implementation will be kept.
2105
+ * All methods will call the original implementation, but you can still track the calls.
2106
+ */
2107
+ spy?: boolean;
2108
+ }
2109
+
2110
+ declare type MockProcedure = (...args: any[]) => any;
2111
+
1996
2112
  declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
1997
2113
 
1998
2114
  declare type MockResult_2<T> = MockResultReturn_2<T> | MockResultThrow_2 | MockResultIncomplete_2;
@@ -2082,9 +2198,10 @@ declare interface Node_2 {
2082
2198
  declare type NormalizedBrowserModeConfig = {
2083
2199
  enabled: boolean;
2084
2200
  provider: 'playwright';
2085
- browser: 'chromium' | 'firefox' | 'webkit';
2201
+ browser: BrowserName;
2086
2202
  headless: boolean;
2087
2203
  port?: number;
2204
+ strictPort: boolean;
2088
2205
  };
2089
2206
 
2090
2207
  declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
@@ -2136,7 +2253,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
2136
2253
 
2137
2254
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2138
2255
 
2139
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'resolveSnapshotPath' | 'extends';
2256
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends';
2140
2257
 
2141
2258
  declare interface Options {
2142
2259
  logger: {
@@ -2203,7 +2320,7 @@ declare type Project = {
2203
2320
  configFilePath?: string;
2204
2321
  };
2205
2322
 
2206
- export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests' | 'bail'>;
2323
+ export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests' | 'hideSkippedTestFiles' | 'bail'>;
2207
2324
 
2208
2325
  declare type ProjectConfigAsyncFn = () => Promise<ProjectConfig | NestedProjectConfig>;
2209
2326
 
@@ -2235,6 +2352,10 @@ declare type PromisifyAssertion<T> = Promisify<Assertion_2<T>>;
2235
2352
 
2236
2353
  declare type PromisifyAssertion_2<T> = Promisify_2<Assertion<T>>;
2237
2354
 
2355
+ declare type Properties<T> = {
2356
+ [K in keyof T]: T[K] extends MockProcedure ? never : K;
2357
+ }[keyof T];
2358
+
2238
2359
  declare interface Range_2 {
2239
2360
  start: Location_3;
2240
2361
  end: Location_3;
@@ -2496,6 +2617,12 @@ export declare interface RstestConfig {
2496
2617
  * @default false
2497
2618
  */
2498
2619
  hideSkippedTests?: boolean;
2620
+ /**
2621
+ * Hide skipped test files logs.
2622
+ *
2623
+ * @default false
2624
+ */
2625
+ hideSkippedTestFiles?: boolean;
2499
2626
  /**
2500
2627
  * Run only tests with a name that matches the regex.
2501
2628
  */
@@ -2668,6 +2795,74 @@ export declare interface RstestUtilities {
2668
2795
  * Determines if the given function is a mocked function.
2669
2796
  */
2670
2797
  isMockFunction: (fn: any) => fn is MockInstance_2;
2798
+ /**
2799
+ * Deeply mocks properties and methods of a given object
2800
+ * in the same way as `rstest.mock()` mocks module exports.
2801
+ *
2802
+ * @example
2803
+ * ```ts
2804
+ * const original = {
2805
+ * simple: () => 'value',
2806
+ * nested: {
2807
+ * method: () => 'real'
2808
+ * },
2809
+ * prop: 'foo',
2810
+ * }
2811
+ *
2812
+ * const mocked = rstest.mockObject(original)
2813
+ * expect(mocked.simple()).toBe(undefined)
2814
+ * expect(mocked.nested.method()).toBe(undefined)
2815
+ * expect(mocked.prop).toBe('foo')
2816
+ *
2817
+ * mocked.simple.mockReturnValue('mocked')
2818
+ * expect(mocked.simple()).toBe('mocked')
2819
+ *
2820
+ * // With spy option to keep original implementations
2821
+ * const spied = rstest.mockObject(original, { spy: true })
2822
+ * expect(spied.simple()).toBe('value')
2823
+ * expect(spied.simple).toHaveBeenCalled()
2824
+ * ```
2825
+ *
2826
+ * @param value - The object to be mocked
2827
+ * @param options - Mock options
2828
+ * @returns A deeply mocked version of the input object
2829
+ */
2830
+ mockObject: <T>(value: T, options?: MockOptions) => MaybeMockedDeep<T>;
2831
+ /**
2832
+ * Type helper for TypeScript. Just returns the object that was passed.
2833
+ *
2834
+ * When `partial` is `true` it will expect a `Partial<T>` as a return value.
2835
+ * By default, this will only make TypeScript believe that the first level values are mocked.
2836
+ * You can pass down `{ deep: true }` as a second argument to tell TypeScript
2837
+ * that the whole object is mocked, if it actually is.
2838
+ *
2839
+ * @example
2840
+ * ```ts
2841
+ * import example from './example.js'
2842
+ *
2843
+ * rstest.mock('./example.js')
2844
+ *
2845
+ * test('1 + 1 equals 10', async () => {
2846
+ * rstest.mocked(example.calc).mockReturnValue(10)
2847
+ * expect(example.calc(1, '+', 1)).toBe(10)
2848
+ * })
2849
+ * ```
2850
+ * @param item - Anything that can be mocked
2851
+ * @returns The same item with mocked type
2852
+ */
2853
+ mocked: (<T>(item: T, deep?: false) => Mocked<T>) & (<T>(item: T, deep: true) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
2854
+ partial?: false;
2855
+ deep?: false;
2856
+ }) => Mocked<T>) & (<T>(item: T, options: {
2857
+ partial?: false;
2858
+ deep: true;
2859
+ }) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
2860
+ partial: true;
2861
+ deep?: false;
2862
+ }) => MaybePartiallyMocked<T>) & (<T>(item: T, options: {
2863
+ partial: true;
2864
+ deep: true;
2865
+ }) => MaybePartiallyMockedDeep<T>);
2671
2866
  /**
2672
2867
  * Calls `.mockClear()` on all spies.
2673
2868
  */
@@ -2681,21 +2876,37 @@ export declare interface RstestUtilities {
2681
2876
  */
2682
2877
  restoreAllMocks: () => RstestUtilities;
2683
2878
  /**
2684
- * Mock a module
2879
+ * Mock a module.
2880
+ *
2881
+ * When called with a factory function, the module will be replaced with the return value of the factory.
2882
+ * When called with `{ spy: true }`, the module will be auto-mocked but the original implementations
2883
+ * will be preserved - all exports will be wrapped in spy functions that track calls.
2884
+ *
2885
+ * @example
2886
+ * ```ts
2887
+ * // Replace module with factory
2888
+ * rs.mock('./module', () => ({ fn: rs.fn() }))
2889
+ *
2890
+ * // Auto-mock with spy mode - keeps original implementations
2891
+ * rs.mock('./module', { spy: true })
2892
+ * ```
2685
2893
  */
2686
- mock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
2894
+ mock<T = unknown>(moduleName: string | Promise<T>, factoryOrOptions?: MockFactory<T> | MockModuleOptions): void;
2687
2895
  /**
2688
- * Mock a module
2896
+ * Mock a module (CommonJS require)
2689
2897
  */
2690
- mockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2898
+ mockRequire: <T = unknown>(moduleName: string, factoryOrOptions?: (() => T) | MockModuleOptions) => void;
2691
2899
  /**
2692
2900
  * Mock a module, not hoisted.
2901
+ *
2902
+ * When called with `{ spy: true }`, the module will be auto-mocked but the original implementations
2903
+ * will be preserved - all exports will be wrapped in spy functions that track calls.
2693
2904
  */
2694
- doMock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
2905
+ doMock<T = unknown>(moduleName: string | Promise<T>, factoryOrOptions?: MockFactory<T> | MockModuleOptions): void;
2695
2906
  /**
2696
- * Mock a module, not hoisted.
2907
+ * Mock a module, not hoisted (CommonJS require).
2697
2908
  */
2698
- doMockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2909
+ doMockRequire: <T = unknown>(moduleName: string, factoryOrOptions?: (() => T) | MockModuleOptions) => void;
2699
2910
  /**
2700
2911
  * Hoisted mock function.
2701
2912
  */
@@ -3276,9 +3487,18 @@ declare interface UserConsoleLog {
3276
3487
  }
3277
3488
 
3278
3489
  declare class VerboseReporter extends DefaultReporter {
3490
+ private verboseOptions;
3491
+ constructor({ rootPath, options, config, testState, }: {
3492
+ rootPath: string;
3493
+ config: NormalizedConfig;
3494
+ options: VerboseReporterOptions;
3495
+ testState: RstestTestState;
3496
+ });
3279
3497
  onTestFileResult(test: TestFileResult): void;
3280
3498
  }
3281
3499
 
3500
+ declare type VerboseReporterOptions = Omit<DefaultReporterOptions, 'summary'>;
3501
+
3282
3502
  declare interface Visitor<N extends Node_2 = Node_2> {
3283
3503
  onStart(root: N, state: any): void;
3284
3504
  onSummary(root: N, state: any): void;
@@ -39,6 +39,32 @@ __webpack_require__.rstest_mock = (id, modFactory)=>{
39
39
  __webpack_require__.rstest_original_modules[id] = requiredModule;
40
40
  __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
41
41
  }
42
+ if (modFactory && 'object' == typeof modFactory) {
43
+ const isSpy = true === modFactory.spy;
44
+ const isMock = true === modFactory.mock;
45
+ if (!isSpy && !isMock) throw new Error('[Rstest] rs.mock() options must be { spy: true } or { mock: true }');
46
+ if (!requiredModule) {
47
+ const optionName = isSpy ? 'spy' : 'mock';
48
+ throw new Error(`[Rstest] rs.mock('${id}', { ${optionName}: true }) failed: cannot load original module`);
49
+ }
50
+ const originalModule = requiredModule;
51
+ const isEsModule = true === originalModule.__esModule;
52
+ const mockedModule = globalThis.RSTEST_API?.rstest?.mockObject(originalModule, {
53
+ spy: isSpy
54
+ }) || originalModule;
55
+ const finalModFactory = function(__unused_webpack_module, __webpack_exports__, __webpack_require__1) {
56
+ __webpack_require__1.r(__webpack_exports__);
57
+ for(const key in mockedModule)__webpack_require__1.d(__webpack_exports__, {
58
+ [key]: ()=>mockedModule[key]
59
+ });
60
+ if (!isEsModule && !('default' in mockedModule)) __webpack_require__1.d(__webpack_exports__, {
61
+ default: ()=>mockedModule
62
+ });
63
+ };
64
+ __webpack_modules__[id] = finalModFactory;
65
+ delete __webpack_module_cache__[id];
66
+ return;
67
+ }
42
68
  if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
43
69
  exports: __webpack_require__(modFactory)
44
70
  };
@@ -62,6 +88,28 @@ __webpack_require__.rstest_mock_require = (id, modFactory)=>{
62
88
  __webpack_require__.rstest_original_modules[id] = requiredModule;
63
89
  __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
64
90
  }
91
+ if (modFactory && 'object' == typeof modFactory) {
92
+ const isSpy = true === modFactory.spy;
93
+ const isMock = true === modFactory.mock;
94
+ if (!isSpy && !isMock) throw new Error('[Rstest] rs.mockRequire() options must be { spy: true } or { mock: true }');
95
+ if (!requiredModule) {
96
+ const optionName = isSpy ? 'spy' : 'mock';
97
+ throw new Error(`[Rstest] rs.mockRequire('${id}', { ${optionName}: true }) failed: cannot load original module`);
98
+ }
99
+ const originalModule = requiredModule;
100
+ const isEsModule = true === originalModule.__esModule;
101
+ const mockedModule = globalThis.RSTEST_API?.rstest?.mockObject(originalModule, {
102
+ spy: isSpy
103
+ }) || originalModule;
104
+ if (isEsModule) __webpack_require__.r(mockedModule);
105
+ else if (!('default' in mockedModule)) mockedModule.default = mockedModule;
106
+ __webpack_module_cache__[id] = {
107
+ exports: mockedModule,
108
+ id,
109
+ loaded: true
110
+ };
111
+ return;
112
+ }
65
113
  if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
66
114
  exports: __webpack_require__(modFactory)
67
115
  };
@@ -83,6 +131,28 @@ __webpack_require__.rstest_do_mock = (id, modFactory)=>{
83
131
  __webpack_require__.rstest_original_modules[id] = requiredModule;
84
132
  __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
85
133
  }
134
+ if (modFactory && 'object' == typeof modFactory) {
135
+ const isSpy = true === modFactory.spy;
136
+ const isMock = true === modFactory.mock;
137
+ if (!isSpy && !isMock) throw new Error('[Rstest] rs.doMock() options must be { spy: true } or { mock: true }');
138
+ if (!requiredModule) {
139
+ const optionName = isSpy ? 'spy' : 'mock';
140
+ throw new Error(`[Rstest] rs.doMock('${id}', { ${optionName}: true }) failed: cannot load original module`);
141
+ }
142
+ const originalModule = requiredModule;
143
+ const isEsModule = true === originalModule.__esModule;
144
+ const mockedModule = globalThis.RSTEST_API?.rstest?.mockObject(originalModule, {
145
+ spy: isSpy
146
+ }) || originalModule;
147
+ if (isEsModule) __webpack_require__.r(mockedModule);
148
+ else if (!('default' in mockedModule)) mockedModule.default = mockedModule;
149
+ __webpack_module_cache__[id] = {
150
+ exports: mockedModule,
151
+ id,
152
+ loaded: true
153
+ };
154
+ return;
155
+ }
86
156
  if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
87
157
  exports: __webpack_require__(modFactory)
88
158
  };
@@ -104,6 +174,28 @@ __webpack_require__.rstest_do_mock_require = (id, modFactory)=>{
104
174
  __webpack_require__.rstest_original_modules[id] = requiredModule;
105
175
  __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
106
176
  }
177
+ if (modFactory && 'object' == typeof modFactory) {
178
+ const isSpy = true === modFactory.spy;
179
+ const isMock = true === modFactory.mock;
180
+ if (!isSpy && !isMock) throw new Error('[Rstest] rs.doMockRequire() options must be { spy: true } or { mock: true }');
181
+ if (!requiredModule) {
182
+ const optionName = isSpy ? 'spy' : 'mock';
183
+ throw new Error(`[Rstest] rs.doMockRequire('${id}', { ${optionName}: true }) failed: cannot load original module`);
184
+ }
185
+ const originalModule = requiredModule;
186
+ const isEsModule = true === originalModule.__esModule;
187
+ const mockedModule = globalThis.RSTEST_API?.rstest?.mockObject(originalModule, {
188
+ spy: isSpy
189
+ }) || originalModule;
190
+ if (isEsModule) __webpack_require__.r(mockedModule);
191
+ else if (!('default' in mockedModule)) mockedModule.default = mockedModule;
192
+ __webpack_module_cache__[id] = {
193
+ exports: mockedModule,
194
+ id,
195
+ loaded: true
196
+ };
197
+ return;
198
+ }
107
199
  if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
108
200
  exports: __webpack_require__(modFactory)
109
201
  };
@@ -29,33 +29,6 @@ __webpack_require__.m = __webpack_modules__;
29
29
  return getter;
30
30
  };
31
31
  })();
32
- (()=>{
33
- var getProto = Object.getPrototypeOf ? (obj)=>Object.getPrototypeOf(obj) : (obj)=>obj.__proto__;
34
- var leafPrototypes;
35
- __webpack_require__.t = function(value, mode) {
36
- if (1 & mode) value = this(value);
37
- if (8 & mode) return value;
38
- if ('object' == typeof value && value) {
39
- if (4 & mode && value.__esModule) return value;
40
- if (16 & mode && 'function' == typeof value.then) return value;
41
- }
42
- var ns = Object.create(null);
43
- __webpack_require__.r(ns);
44
- var def = {};
45
- leafPrototypes = leafPrototypes || [
46
- null,
47
- getProto({}),
48
- getProto([]),
49
- getProto(getProto)
50
- ];
51
- for(var current = 2 & mode && value; ('object' == typeof current || 'function' == typeof current) && !~leafPrototypes.indexOf(current); current = getProto(current))Object.getOwnPropertyNames(current).forEach((key)=>{
52
- def[key] = ()=>value[key];
53
- });
54
- def['default'] = ()=>value;
55
- __webpack_require__.d(ns, def);
56
- return ns;
57
- };
58
- })();
59
32
  (()=>{
60
33
  __webpack_require__.d = (exports, definition)=>{
61
34
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {