@rstest/core 0.8.2 → 0.8.4
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/0~130.js +1 -2
- package/dist/0~1472.js +2 -3
- package/dist/0~1981.js +1 -2
- package/dist/0~2173.js +6 -4
- package/dist/0~2255.js +2 -3
- package/dist/0~3062.js +1 -2
- package/dist/0~3346.js +1 -2
- package/dist/0~3919.js +1 -2
- package/dist/0~4403.js +1 -2
- package/dist/0~4809.js +1 -2
- package/dist/0~5835.js +6 -10
- package/dist/0~62.js +1 -2
- package/dist/0~6588.js +5 -5
- package/dist/0~6907.js +1 -2
- package/dist/0~6923.js +6 -10
- package/dist/0~7583.js +3 -4
- package/dist/0~7882.js +7 -8
- package/dist/0~8426.js +1 -2
- package/dist/0~89.js +212 -15
- package/dist/0~9348.js +1 -2
- package/dist/0~9634.js +5 -5
- package/dist/1157.js +4 -97
- package/dist/1294.js +1 -2
- package/dist/1672.js +1 -2
- package/dist/3160.js +106 -10
- package/dist/4397.js +1 -2
- package/dist/4484.js +1 -2
- package/dist/487.js +3 -4
- package/dist/4881.js +1 -2
- package/dist/4899.js +2 -2
- package/dist/5734.js +1 -2
- package/dist/6151.js +9 -2
- package/dist/6198.js +1 -2
- package/dist/6973.js +2 -3
- package/dist/7011.js +1 -2
- package/dist/721.js +1 -2
- package/dist/9131.js +35 -32
- package/dist/{3216.js → 9869.js} +20 -3
- package/dist/browser-runtime/389.js +9 -0
- package/dist/browser-runtime/389.js.LICENSE.txt +22 -0
- package/dist/browser-runtime/index.d.ts +27 -1
- package/dist/browser.d.ts +29 -1
- package/dist/browser.js +1 -2
- package/dist/globalSetupWorker.js +5 -6
- package/dist/index.d.ts +27 -1
- package/dist/index.js +1 -2
- package/dist/mockRuntimeCode.js +63 -174
- package/dist/rslib-runtime.js +1 -2
- package/dist/worker.d.ts +27 -1
- package/dist/worker.js +30 -20
- package/package.json +2 -2
- /package/dist/{1157.js.LICENSE.txt → 3160.js.LICENSE.txt} +0 -0
|
@@ -18133,6 +18133,7 @@ let createLogger = (options = {})=>{
|
|
|
18133
18133
|
return logger;
|
|
18134
18134
|
};
|
|
18135
18135
|
let src_logger = createLogger();
|
|
18136
|
+
__webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
18136
18137
|
const picocolors_browser = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.browser.js");
|
|
18137
18138
|
var logger_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
18138
18139
|
const isDebug = ()=>{
|
|
@@ -22391,6 +22392,14 @@ const initSpy = ()=>{
|
|
|
22391
22392
|
}, defaultName, mockFn);
|
|
22392
22393
|
};
|
|
22393
22394
|
const spyOn = (obj, methodName, accessType)=>{
|
|
22395
|
+
if (accessType) {
|
|
22396
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
|
|
22397
|
+
const accessor = 'get' === accessType ? Reflect.get(descriptor ?? {}, 'get') : Reflect.get(descriptor ?? {}, 'set');
|
|
22398
|
+
if ('function' == typeof accessor && spy_isMockFunction(accessor)) return accessor;
|
|
22399
|
+
} else {
|
|
22400
|
+
const method = obj[methodName];
|
|
22401
|
+
if (spy_isMockFunction(method)) return method;
|
|
22402
|
+
}
|
|
22394
22403
|
const accessTypeMap = {
|
|
22395
22404
|
get: 'getter',
|
|
22396
22405
|
set: 'setter'
|
|
@@ -135,6 +135,28 @@
|
|
|
135
135
|
* MIT Licensed
|
|
136
136
|
*/
|
|
137
137
|
|
|
138
|
+
/*!
|
|
139
|
+
* Copyright 2017 Vercel, Inc.
|
|
140
|
+
*
|
|
141
|
+
* This file is derived from Vercel's detect-agent:
|
|
142
|
+
* https://github.com/vercel/vercel/tree/main/packages/detect-agent
|
|
143
|
+
*
|
|
144
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
145
|
+
* you may not use this file except in compliance with the License.
|
|
146
|
+
* You may obtain a copy of the License at
|
|
147
|
+
*
|
|
148
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
149
|
+
*
|
|
150
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
151
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
152
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
153
|
+
* See the License for the specific language governing permissions and
|
|
154
|
+
* limitations under the License.
|
|
155
|
+
*
|
|
156
|
+
* Modifications in this derived work:
|
|
157
|
+
* - Removed async determine logic, kept only env detection.
|
|
158
|
+
*/
|
|
159
|
+
|
|
138
160
|
/*!
|
|
139
161
|
* The buffer module from node.js, for the browser.
|
|
140
162
|
*
|
|
@@ -319,6 +319,12 @@ declare type BrowserModeConfig = {
|
|
|
319
319
|
* If not specified, a random available port will be used.
|
|
320
320
|
*/
|
|
321
321
|
port?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Default runner iframe viewport.
|
|
324
|
+
*
|
|
325
|
+
* When not specified, the browser UI fills the preview panel.
|
|
326
|
+
*/
|
|
327
|
+
viewport?: BrowserViewport;
|
|
322
328
|
/**
|
|
323
329
|
* Whether to exit if the specified port is already in use.
|
|
324
330
|
*
|
|
@@ -336,6 +342,11 @@ declare type BrowserModeConfig = {
|
|
|
336
342
|
*/
|
|
337
343
|
declare type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
338
344
|
|
|
345
|
+
declare type BrowserViewport = {
|
|
346
|
+
width: number;
|
|
347
|
+
height: number;
|
|
348
|
+
} | DevicePreset;
|
|
349
|
+
|
|
339
350
|
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
340
351
|
|
|
341
352
|
declare type BuiltinReporterOptions = {
|
|
@@ -633,6 +644,20 @@ declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
|
633
644
|
|
|
634
645
|
declare type DescribeForFn = <T>(cases: readonly T[]) => (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
635
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Device presets aligned with Chrome DevTools device toolbar.
|
|
649
|
+
*
|
|
650
|
+
* These values are stable identifiers (not user-facing labels).
|
|
651
|
+
*
|
|
652
|
+
* IMPORTANT: Keep this union in sync with
|
|
653
|
+
* `@rstest/browser` preset runtime source:
|
|
654
|
+
* `packages/browser/src/viewportPresets.ts`.
|
|
655
|
+
*
|
|
656
|
+
* `@rstest/core` owns `defineConfig` typing, while `@rstest/browser` owns
|
|
657
|
+
* runtime validation and resolution for preset ids.
|
|
658
|
+
*/
|
|
659
|
+
declare type DevicePreset = 'iPhoneSE' | 'iPhoneXR' | 'iPhone12Pro' | 'iPhone14ProMax' | 'Pixel7' | 'SamsungGalaxyS8Plus' | 'SamsungGalaxyS20Ultra' | 'iPadMini' | 'iPadAir' | 'iPadPro' | 'SurfacePro7' | 'SurfaceDuo' | 'GalaxyZFold5' | 'AsusZenbookFold' | 'SamsungGalaxyA51A71' | 'NestHub' | 'NestHubMax';
|
|
660
|
+
|
|
636
661
|
/** The test file output path */
|
|
637
662
|
declare type DistPath = string;
|
|
638
663
|
|
|
@@ -1680,6 +1705,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
1680
1705
|
headless: boolean;
|
|
1681
1706
|
port?: number;
|
|
1682
1707
|
strictPort: boolean;
|
|
1708
|
+
viewport?: BrowserViewport;
|
|
1683
1709
|
};
|
|
1684
1710
|
|
|
1685
1711
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -1751,7 +1777,7 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
|
|
|
1751
1777
|
|
|
1752
1778
|
declare type Procedure = (...args: any[]) => any;
|
|
1753
1779
|
|
|
1754
|
-
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | '
|
|
1780
|
+
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
|
|
1755
1781
|
|
|
1756
1782
|
declare type ProjectContext = {
|
|
1757
1783
|
name: string;
|
package/dist/browser.d.ts
CHANGED
|
@@ -315,6 +315,12 @@ declare type BrowserModeConfig = {
|
|
|
315
315
|
* If not specified, a random available port will be used.
|
|
316
316
|
*/
|
|
317
317
|
port?: number;
|
|
318
|
+
/**
|
|
319
|
+
* Default runner iframe viewport.
|
|
320
|
+
*
|
|
321
|
+
* When not specified, the browser UI fills the preview panel.
|
|
322
|
+
*/
|
|
323
|
+
viewport?: BrowserViewport;
|
|
318
324
|
/**
|
|
319
325
|
* Whether to exit if the specified port is already in use.
|
|
320
326
|
*
|
|
@@ -367,8 +373,15 @@ export declare interface BrowserTestRunResult {
|
|
|
367
373
|
};
|
|
368
374
|
/** Whether the test run had failures */
|
|
369
375
|
hasFailure: boolean;
|
|
376
|
+
/** Errors that occurred before/outside test execution (e.g., browser launch failure) */
|
|
377
|
+
unhandledErrors?: Error[];
|
|
370
378
|
}
|
|
371
379
|
|
|
380
|
+
declare type BrowserViewport = {
|
|
381
|
+
width: number;
|
|
382
|
+
height: number;
|
|
383
|
+
} | DevicePreset;
|
|
384
|
+
|
|
372
385
|
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
373
386
|
|
|
374
387
|
declare type BuiltinReporterOptions = {
|
|
@@ -766,6 +779,20 @@ declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
|
766
779
|
|
|
767
780
|
declare type DescribeForFn = <T>(cases: readonly T[]) => (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
768
781
|
|
|
782
|
+
/**
|
|
783
|
+
* Device presets aligned with Chrome DevTools device toolbar.
|
|
784
|
+
*
|
|
785
|
+
* These values are stable identifiers (not user-facing labels).
|
|
786
|
+
*
|
|
787
|
+
* IMPORTANT: Keep this union in sync with
|
|
788
|
+
* `@rstest/browser` preset runtime source:
|
|
789
|
+
* `packages/browser/src/viewportPresets.ts`.
|
|
790
|
+
*
|
|
791
|
+
* `@rstest/core` owns `defineConfig` typing, while `@rstest/browser` owns
|
|
792
|
+
* runtime validation and resolution for preset ids.
|
|
793
|
+
*/
|
|
794
|
+
export declare type DevicePreset = 'iPhoneSE' | 'iPhoneXR' | 'iPhone12Pro' | 'iPhone14ProMax' | 'Pixel7' | 'SamsungGalaxyS8Plus' | 'SamsungGalaxyS20Ultra' | 'iPadMini' | 'iPadAir' | 'iPadPro' | 'SurfacePro7' | 'SurfaceDuo' | 'GalaxyZFold5' | 'AsusZenbookFold' | 'SamsungGalaxyA51A71' | 'NestHub' | 'NestHubMax';
|
|
795
|
+
|
|
769
796
|
/**
|
|
770
797
|
* @param a Expected value
|
|
771
798
|
* @param b Received value
|
|
@@ -2195,6 +2222,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
2195
2222
|
headless: boolean;
|
|
2196
2223
|
port?: number;
|
|
2197
2224
|
strictPort: boolean;
|
|
2225
|
+
viewport?: BrowserViewport;
|
|
2198
2226
|
};
|
|
2199
2227
|
|
|
2200
2228
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -2321,7 +2349,7 @@ declare type Project = {
|
|
|
2321
2349
|
configFilePath?: string;
|
|
2322
2350
|
};
|
|
2323
2351
|
|
|
2324
|
-
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | '
|
|
2352
|
+
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
|
|
2325
2353
|
|
|
2326
2354
|
export declare type ProjectContext = {
|
|
2327
2355
|
name: string;
|
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
export { TEMP_RSTEST_OUTPUT_DIR, getTestEntries, globalApis } from "./1157.js";
|
|
4
3
|
export { afterAll, afterEach, assert, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished, rs, rsbuild, rstest, test } from "./4484.js";
|
|
5
4
|
export { color, isDebug, logger, serializableConfig } from "./3160.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
3
|
import "./487.js";
|
|
5
4
|
import { color } from "./3160.js";
|
|
@@ -43,12 +42,12 @@ const runGlobalSetup = async (data)=>{
|
|
|
43
42
|
const { loadModule } = data.outputModule ? await import("./0~6923.js").then((mod)=>({
|
|
44
43
|
EsmMode: mod.loadEsModule_EsmMode,
|
|
45
44
|
asModule: mod.asModule,
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
clearModuleCache: mod.clearModuleCache,
|
|
46
|
+
loadModule: mod.loadModule
|
|
48
47
|
})) : await import("./0~5835.js").then((mod)=>({
|
|
49
48
|
cacheableLoadModule: mod.cacheableLoadModule,
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
clearModuleCache: mod.clearModuleCache,
|
|
50
|
+
loadModule: mod.loadModule
|
|
52
51
|
}));
|
|
53
52
|
const module = await loadModule({
|
|
54
53
|
codeContent: setupCodeContent,
|
package/dist/index.d.ts
CHANGED
|
@@ -295,6 +295,12 @@ declare type BrowserModeConfig = {
|
|
|
295
295
|
* If not specified, a random available port will be used.
|
|
296
296
|
*/
|
|
297
297
|
port?: number;
|
|
298
|
+
/**
|
|
299
|
+
* Default runner iframe viewport.
|
|
300
|
+
*
|
|
301
|
+
* When not specified, the browser UI fills the preview panel.
|
|
302
|
+
*/
|
|
303
|
+
viewport?: BrowserViewport;
|
|
298
304
|
/**
|
|
299
305
|
* Whether to exit if the specified port is already in use.
|
|
300
306
|
*
|
|
@@ -312,6 +318,11 @@ declare type BrowserModeConfig = {
|
|
|
312
318
|
*/
|
|
313
319
|
declare type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
314
320
|
|
|
321
|
+
declare type BrowserViewport = {
|
|
322
|
+
width: number;
|
|
323
|
+
height: number;
|
|
324
|
+
} | DevicePreset;
|
|
325
|
+
|
|
315
326
|
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
316
327
|
|
|
317
328
|
declare type BuiltinReporterOptions = {
|
|
@@ -780,6 +791,20 @@ declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
|
780
791
|
|
|
781
792
|
declare type DescribeForFn = <T>(cases: readonly T[]) => (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
782
793
|
|
|
794
|
+
/**
|
|
795
|
+
* Device presets aligned with Chrome DevTools device toolbar.
|
|
796
|
+
*
|
|
797
|
+
* These values are stable identifiers (not user-facing labels).
|
|
798
|
+
*
|
|
799
|
+
* IMPORTANT: Keep this union in sync with
|
|
800
|
+
* `@rstest/browser` preset runtime source:
|
|
801
|
+
* `packages/browser/src/viewportPresets.ts`.
|
|
802
|
+
*
|
|
803
|
+
* `@rstest/core` owns `defineConfig` typing, while `@rstest/browser` owns
|
|
804
|
+
* runtime validation and resolution for preset ids.
|
|
805
|
+
*/
|
|
806
|
+
declare type DevicePreset = 'iPhoneSE' | 'iPhoneXR' | 'iPhone12Pro' | 'iPhone14ProMax' | 'Pixel7' | 'SamsungGalaxyS8Plus' | 'SamsungGalaxyS20Ultra' | 'iPadMini' | 'iPadAir' | 'iPadPro' | 'SurfacePro7' | 'SurfaceDuo' | 'GalaxyZFold5' | 'AsusZenbookFold' | 'SamsungGalaxyA51A71' | 'NestHub' | 'NestHubMax';
|
|
807
|
+
|
|
783
808
|
/**
|
|
784
809
|
* @param a Expected value
|
|
785
810
|
* @param b Received value
|
|
@@ -2215,6 +2240,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
2215
2240
|
headless: boolean;
|
|
2216
2241
|
port?: number;
|
|
2217
2242
|
strictPort: boolean;
|
|
2243
|
+
viewport?: BrowserViewport;
|
|
2218
2244
|
};
|
|
2219
2245
|
|
|
2220
2246
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -2333,7 +2359,7 @@ declare type Project = {
|
|
|
2333
2359
|
configFilePath?: string;
|
|
2334
2360
|
};
|
|
2335
2361
|
|
|
2336
|
-
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | '
|
|
2362
|
+
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
|
|
2337
2363
|
|
|
2338
2364
|
declare type ProjectConfigAsyncFn = () => Promise<ProjectConfig | NestedProjectConfig>;
|
|
2339
2365
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
export { afterAll, afterEach, assert, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished, rs, rstest, test } from "./4484.js";
|
|
4
3
|
export { createRstest, defineConfig, defineProject, initCli, loadConfig, mergeProjectConfig, mergeRstestConfig, runCLI } from "./9131.js";
|
package/dist/mockRuntimeCode.js
CHANGED
|
@@ -28,187 +28,76 @@ __webpack_require__.rstest_unmock = (id)=>{
|
|
|
28
28
|
__webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
|
|
29
29
|
__webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
|
|
30
30
|
const originalModule = __webpack_require__.rstest_original_modules[id];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
requiredModule = __webpack_require__(id);
|
|
38
|
-
} catch {} finally{
|
|
39
|
-
__webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
40
|
-
__webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
|
|
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
|
-
}
|
|
68
|
-
if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
|
|
69
|
-
exports: __webpack_require__(modFactory)
|
|
70
|
-
};
|
|
71
|
-
else if ('function' == typeof modFactory) {
|
|
72
|
-
const finalModFactory = function(__unused_webpack_module, __webpack_exports__, __webpack_require__1) {
|
|
73
|
-
__webpack_require__1.r(__webpack_exports__);
|
|
74
|
-
const res = modFactory();
|
|
75
|
-
for(const key in res)__webpack_require__1.d(__webpack_exports__, {
|
|
76
|
-
[key]: ()=>res[key]
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
__webpack_modules__[id] = finalModFactory;
|
|
80
|
-
delete __webpack_module_cache__[id];
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
__webpack_require__.rstest_mock_require = (id, modFactory)=>{
|
|
84
|
-
let requiredModule;
|
|
85
|
-
try {
|
|
86
|
-
requiredModule = __webpack_require__(id);
|
|
87
|
-
} catch {} finally{
|
|
88
|
-
__webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
89
|
-
__webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
|
|
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
|
-
}
|
|
113
|
-
if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
|
|
114
|
-
exports: __webpack_require__(modFactory)
|
|
115
|
-
};
|
|
116
|
-
else if ('function' == typeof modFactory) {
|
|
117
|
-
const exports = modFactory();
|
|
118
|
-
__webpack_require__.r(exports);
|
|
119
|
-
__webpack_module_cache__[id] = {
|
|
120
|
-
exports,
|
|
121
|
-
id,
|
|
122
|
-
loaded: true
|
|
31
|
+
if (originalModule) return originalModule;
|
|
32
|
+
if (id in __webpack_require__.rstest_original_module_factories) {
|
|
33
|
+
const mod = __webpack_require__.rstest_original_module_factories[id];
|
|
34
|
+
const moduleInstance = {
|
|
35
|
+
exports: {}
|
|
123
36
|
};
|
|
37
|
+
mod(moduleInstance, moduleInstance.exports, __webpack_require__);
|
|
38
|
+
__webpack_require__.rstest_original_modules[id] = moduleInstance.exports;
|
|
39
|
+
return moduleInstance.exports;
|
|
124
40
|
}
|
|
41
|
+
return __webpack_require__(id);
|
|
125
42
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
__webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
43
|
+
const getMockImplementation = (mockType = 'mock')=>(id, modFactory)=>{
|
|
44
|
+
let requiredModule = __webpack_module_cache__[id]?.exports;
|
|
45
|
+
const wasAlreadyLoaded = !!requiredModule;
|
|
46
|
+
if (requiredModule) {
|
|
47
|
+
__webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
48
|
+
__webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
|
|
49
|
+
} else __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
|
|
50
|
+
if (modFactory && 'object' == typeof modFactory) {
|
|
51
|
+
const isSpy = true === modFactory.spy;
|
|
52
|
+
const isMock = true === modFactory.mock;
|
|
53
|
+
if (!isSpy && !isMock) throw new Error(`[Rstest] rs.${mockType}() options must be { spy: true } or { mock: true }`);
|
|
54
|
+
if (!wasAlreadyLoaded) try {
|
|
55
|
+
requiredModule = __webpack_require__(id);
|
|
56
|
+
} catch {
|
|
57
|
+
const optionName = isSpy ? 'spy' : 'mock';
|
|
58
|
+
throw new Error(`[Rstest] rs.${mockType}('${id}', { ${optionName}: true }) failed: cannot load original module`);
|
|
59
|
+
}
|
|
60
|
+
if (!requiredModule) {
|
|
61
|
+
const optionName = isSpy ? 'spy' : 'mock';
|
|
62
|
+
throw new Error(`[Rstest] rs.${mockType}('${id}', { ${optionName}: true }) failed: cannot load original module`);
|
|
63
|
+
}
|
|
64
|
+
const originalModule = requiredModule;
|
|
65
|
+
const isEsModule = true === originalModule.__esModule;
|
|
66
|
+
const mockedModule = globalThis.RSTEST_API?.rstest?.mockObject(originalModule, {
|
|
67
|
+
spy: isSpy
|
|
68
|
+
}) || originalModule;
|
|
69
|
+
const finalModFactory = function(__unused_webpack_module, __webpack_exports__, __webpack_require__1) {
|
|
70
|
+
__webpack_require__1.r(__webpack_exports__);
|
|
71
|
+
for(const key in mockedModule)__webpack_require__1.d(__webpack_exports__, {
|
|
72
|
+
[key]: ()=>mockedModule[key]
|
|
73
|
+
});
|
|
74
|
+
if (!isEsModule && !('default' in mockedModule)) __webpack_require__1.d(__webpack_exports__, {
|
|
75
|
+
default: ()=>mockedModule
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
__webpack_modules__[id] = finalModFactory;
|
|
79
|
+
delete __webpack_module_cache__[id];
|
|
80
|
+
return;
|
|
141
81
|
}
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
}
|
|
156
|
-
if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
|
|
157
|
-
exports: __webpack_require__(modFactory)
|
|
158
|
-
};
|
|
159
|
-
else if ('function' == typeof modFactory) {
|
|
160
|
-
const exports = modFactory();
|
|
161
|
-
__webpack_require__.r(exports);
|
|
162
|
-
__webpack_module_cache__[id] = {
|
|
163
|
-
exports,
|
|
164
|
-
id,
|
|
165
|
-
loaded: true
|
|
82
|
+
if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
|
|
83
|
+
exports: __webpack_require__(modFactory)
|
|
166
84
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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`);
|
|
85
|
+
else if ('function' == typeof modFactory) {
|
|
86
|
+
const finalModFactory = function(__unused_webpack_module, __webpack_exports__, __webpack_require__1) {
|
|
87
|
+
__webpack_require__1.r(__webpack_exports__);
|
|
88
|
+
const res = modFactory();
|
|
89
|
+
for(const key in res)__webpack_require__1.d(__webpack_exports__, {
|
|
90
|
+
[key]: ()=>res[key]
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
__webpack_modules__[id] = finalModFactory;
|
|
94
|
+
delete __webpack_module_cache__[id];
|
|
184
95
|
}
|
|
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
|
-
}
|
|
199
|
-
if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
|
|
200
|
-
exports: __webpack_require__(modFactory)
|
|
201
96
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
exports,
|
|
207
|
-
id,
|
|
208
|
-
loaded: true
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
};
|
|
97
|
+
__webpack_require__.rstest_mock = getMockImplementation('mock');
|
|
98
|
+
__webpack_require__.rstest_mock_require = getMockImplementation('mockRequire');
|
|
99
|
+
__webpack_require__.rstest_do_mock = getMockImplementation('doMock');
|
|
100
|
+
__webpack_require__.rstest_do_mock_require = getMockImplementation('doMockRequire');
|
|
212
101
|
__webpack_require__.rstest_reset_modules = ()=>{
|
|
213
102
|
const mockedIds = Object.keys(__webpack_require__.rstest_original_modules);
|
|
214
103
|
Object.keys(__webpack_module_cache__).forEach((id)=>{
|
package/dist/rslib-runtime.js
CHANGED
package/dist/worker.d.ts
CHANGED
|
@@ -282,6 +282,12 @@ declare type BrowserModeConfig = {
|
|
|
282
282
|
* If not specified, a random available port will be used.
|
|
283
283
|
*/
|
|
284
284
|
port?: number;
|
|
285
|
+
/**
|
|
286
|
+
* Default runner iframe viewport.
|
|
287
|
+
*
|
|
288
|
+
* When not specified, the browser UI fills the preview panel.
|
|
289
|
+
*/
|
|
290
|
+
viewport?: BrowserViewport;
|
|
285
291
|
/**
|
|
286
292
|
* Whether to exit if the specified port is already in use.
|
|
287
293
|
*
|
|
@@ -299,6 +305,11 @@ declare type BrowserModeConfig = {
|
|
|
299
305
|
*/
|
|
300
306
|
declare type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
301
307
|
|
|
308
|
+
declare type BrowserViewport = {
|
|
309
|
+
width: number;
|
|
310
|
+
height: number;
|
|
311
|
+
} | DevicePreset;
|
|
312
|
+
|
|
302
313
|
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
303
314
|
|
|
304
315
|
declare type BuiltinReporterOptions = {
|
|
@@ -635,6 +646,20 @@ declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
|
635
646
|
|
|
636
647
|
declare type DescribeForFn = <T>(cases: readonly T[]) => (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
637
648
|
|
|
649
|
+
/**
|
|
650
|
+
* Device presets aligned with Chrome DevTools device toolbar.
|
|
651
|
+
*
|
|
652
|
+
* These values are stable identifiers (not user-facing labels).
|
|
653
|
+
*
|
|
654
|
+
* IMPORTANT: Keep this union in sync with
|
|
655
|
+
* `@rstest/browser` preset runtime source:
|
|
656
|
+
* `packages/browser/src/viewportPresets.ts`.
|
|
657
|
+
*
|
|
658
|
+
* `@rstest/core` owns `defineConfig` typing, while `@rstest/browser` owns
|
|
659
|
+
* runtime validation and resolution for preset ids.
|
|
660
|
+
*/
|
|
661
|
+
declare type DevicePreset = 'iPhoneSE' | 'iPhoneXR' | 'iPhone12Pro' | 'iPhone14ProMax' | 'Pixel7' | 'SamsungGalaxyS8Plus' | 'SamsungGalaxyS20Ultra' | 'iPadMini' | 'iPadAir' | 'iPadPro' | 'SurfacePro7' | 'SurfaceDuo' | 'GalaxyZFold5' | 'AsusZenbookFold' | 'SamsungGalaxyA51A71' | 'NestHub' | 'NestHubMax';
|
|
662
|
+
|
|
638
663
|
/**
|
|
639
664
|
* @param a Expected value
|
|
640
665
|
* @param b Received value
|
|
@@ -1765,6 +1790,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
1765
1790
|
headless: boolean;
|
|
1766
1791
|
port?: number;
|
|
1767
1792
|
strictPort: boolean;
|
|
1793
|
+
viewport?: BrowserViewport;
|
|
1768
1794
|
};
|
|
1769
1795
|
|
|
1770
1796
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -1870,7 +1896,7 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
|
|
|
1870
1896
|
|
|
1871
1897
|
declare type Procedure = (...args: any[]) => any;
|
|
1872
1898
|
|
|
1873
|
-
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | '
|
|
1899
|
+
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'>;
|
|
1874
1900
|
|
|
1875
1901
|
declare type ProjectContext = {
|
|
1876
1902
|
name: string;
|