@rstest/browser 0.10.3 → 0.10.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 (64) hide show
  1. package/dist/626.js +2 -1
  2. package/dist/browser-container/container-static/css/index.0521ff95b1.css +1 -0
  3. package/dist/browser-container/container-static/js/{27.099feaf1da.js → 854.c59f71483d.js} +5728 -5756
  4. package/dist/browser-container/container-static/js/854.c59f71483d.js.LICENSE.txt +1 -0
  5. package/dist/browser-container/container-static/js/{index.be8c8d2626.js → index.fedc31dff3.js} +109 -136
  6. package/dist/browser-container/container-static/js/{lib-react.5ae9b90ee5.js → lib-react.62b27a21db.js} +21 -21
  7. package/dist/browser-container/container-static/js/lib-react.62b27a21db.js.LICENSE.txt +1 -0
  8. package/dist/browser-container/index.html +1 -1
  9. package/dist/browser.js +4 -4
  10. package/dist/browserRpcRegistry.d.ts +1 -2
  11. package/dist/client/api.d.ts +1 -1
  12. package/dist/client/dispatchTransport.d.ts +18 -1
  13. package/dist/client/locator.d.ts +2 -3
  14. package/dist/concurrency.d.ts +5 -3
  15. package/dist/configValidation.d.ts +2 -2
  16. package/dist/dispatchCapabilities.d.ts +3 -3
  17. package/dist/dispatchRouter.d.ts +2 -3
  18. package/dist/headedSerialTaskQueue.d.ts +5 -5
  19. package/dist/headlessLatestRerunScheduler.d.ts +2 -3
  20. package/dist/headlessTransport.d.ts +2 -3
  21. package/dist/hostController.d.ts +12 -9
  22. package/dist/index.d.ts +6 -6
  23. package/dist/index.js +169 -216
  24. package/dist/protocol.d.ts +78 -55
  25. package/dist/providers/index.d.ts +18 -20
  26. package/dist/providers/playwright/dispatchBrowserRpc.d.ts +5 -3
  27. package/dist/providers/playwright/expectUtils.d.ts +2 -3
  28. package/dist/providers/playwright/implementation.d.ts +1 -1
  29. package/dist/providers/playwright/runtime.d.ts +1 -1
  30. package/dist/rpcProtocol.d.ts +36 -29
  31. package/dist/runSession.d.ts +3 -5
  32. package/dist/sessionRegistry.d.ts +2 -3
  33. package/dist/sourceMap/sourceMapLoader.d.ts +2 -2
  34. package/dist/viewportPresets.d.ts +7 -3
  35. package/dist/watchCliShortcuts.d.ts +1 -1
  36. package/dist/watchRerunPlanner.d.ts +2 -2
  37. package/package.json +7 -9
  38. package/src/AGENTS.md +7 -1
  39. package/src/browserRpcRegistry.ts +2 -2
  40. package/src/client/dispatchTransport.ts +63 -1
  41. package/src/client/entry.ts +25 -58
  42. package/src/client/public.ts +3 -3
  43. package/src/client/snapshot.ts +24 -22
  44. package/src/client/sourceMapSupport.ts +1 -1
  45. package/src/concurrency.ts +7 -21
  46. package/src/configValidation.ts +2 -2
  47. package/src/dispatchCapabilities.ts +102 -83
  48. package/src/env.d.ts +6 -2
  49. package/src/headedSerialTaskQueue.ts +5 -1
  50. package/src/hostController.ts +85 -43
  51. package/src/index.ts +22 -11
  52. package/src/protocol.ts +66 -22
  53. package/src/providers/index.ts +8 -1
  54. package/src/rpcProtocol.ts +34 -21
  55. package/src/viewportPresets.ts +5 -0
  56. package/src/watchCliShortcuts.ts +2 -4
  57. package/dist/browser-container/container-static/css/index.5c72297783.css +0 -1
  58. package/dist/browser-container/container-static/js/27.099feaf1da.js.LICENSE.txt +0 -1
  59. package/dist/browser-container/container-static/js/lib-react.5ae9b90ee5.js.LICENSE.txt +0 -1
  60. package/dist/client/entry.d.ts +0 -4
  61. package/dist/client/fakeTimersStub.d.ts +0 -25
  62. package/dist/client/public.d.ts +0 -9
  63. package/dist/client/snapshot.d.ts +0 -29
  64. package/dist/client/sourceMapSupport.d.ts +0 -42
@@ -1,22 +1,22 @@
1
- import type { DevicePreset } from '@rstest/core/browser';
2
- import type { RuntimeConfig, TestFileResult, TestInfo, TestResult } from '@rstest/core/browser-runtime';
1
+ import type { BrowserViewport } from '@rstest/core/internal/browser';
2
+ import type { RuntimeConfig, TestFileResult, TestInfo, TestResult } from '@rstest/core/internal/browser-runtime';
3
3
  import type { SnapshotUpdateState } from '@vitest/snapshot';
4
- export type { BrowserLocatorIR, BrowserRpcRequest, SnapshotRpcRequest, } from './rpcProtocol.js';
4
+ export type { BrowserLocatorIR, BrowserRpcRequest, SnapshotRpcCall, SnapshotRpcMethod, SnapshotRpcMethodArgs, SnapshotRpcRequest } from './rpcProtocol.js';
5
5
  export { validateBrowserRpcRequest } from './rpcProtocol.js';
6
- export declare const DISPATCH_MESSAGE_TYPE = "__rstest_dispatch__";
7
- export declare const DISPATCH_RESPONSE_TYPE = "__rstest_dispatch_response__";
8
- export declare const DISPATCH_RPC_BRIDGE_NAME = "__rstest_dispatch_rpc__";
9
- export declare const DISPATCH_RPC_REQUEST_TYPE = "dispatch-rpc-request";
10
- export declare const RSTEST_CONFIG_MESSAGE_TYPE = "RSTEST_CONFIG";
11
- export declare const DISPATCH_NAMESPACE_RUNNER = "runner";
12
- export declare const DISPATCH_NAMESPACE_BROWSER = "browser";
13
- export declare const DISPATCH_NAMESPACE_SNAPSHOT = "snapshot";
14
- export declare const DISPATCH_METHOD_RPC = "rpc";
6
+ export declare const DISPATCH_MESSAGE_TYPE = '__rstest_dispatch__';
7
+ export declare const DISPATCH_RESPONSE_TYPE = '__rstest_dispatch_response__';
8
+ export declare const DISPATCH_RPC_BRIDGE_NAME = '__rstest_dispatch_rpc__';
9
+ export declare const DISPATCH_RPC_REQUEST_TYPE = 'dispatch-rpc-request';
10
+ export declare const RSTEST_CONFIG_MESSAGE_TYPE = 'RSTEST_CONFIG';
11
+ export declare const DISPATCH_NAMESPACE_RUNNER = 'runner';
12
+ export declare const DISPATCH_NAMESPACE_BROWSER = 'browser';
13
+ export declare const DISPATCH_NAMESPACE_SNAPSHOT = 'snapshot';
14
+ export declare const DISPATCH_METHOD_RPC = 'rpc';
15
15
  export type SerializedRuntimeConfig = RuntimeConfig;
16
- export type BrowserViewport = {
17
- width: number;
18
- height: number;
19
- } | DevicePreset;
16
+ // `BrowserViewport` is a core config type (`@rstest/core` owns the canonical
17
+ // definition used by `NormalizedBrowserModeConfig`). Re-export it so the host
18
+ // assigns the SAME type across the seam instead of a hand-copied duplicate.
19
+ export type { BrowserViewport };
20
20
  export type BrowserProjectRuntime = {
21
21
  name: string;
22
22
  environmentName: string;
@@ -27,8 +27,7 @@ export type BrowserProjectRuntime = {
27
27
  /**
28
28
  * Test file info with associated project name.
29
29
  * Used to track which project a test file belongs to.
30
- */
31
- export type TestFileInfo = {
30
+ */ export type TestFileInfo = {
32
31
  testPath: string;
33
32
  projectName: string;
34
33
  };
@@ -36,8 +35,24 @@ export type TestFileInfo = {
36
35
  * Execution mode for browser tests.
37
36
  * - 'run': Execute tests and report results (default)
38
37
  * - 'collect': Only collect test metadata without running
39
- */
40
- export type BrowserExecutionMode = 'run' | 'collect';
38
+ */ export type BrowserExecutionMode = 'run' | 'collect';
39
+ /**
40
+ * Wire shape of a `log` client message payload. The host receives this and maps
41
+ * it onto core's {@link UserConsoleLog} (notably `level` → `name`); that mapper
42
+ * (`hostController.ts` `handleLog`) annotates its result as `UserConsoleLog`, so
43
+ * the map→core direction is compiler-checked. Owning the wire shape here as one
44
+ * named type keeps the host's input type from drifting away from the producer.
45
+ */ export type BrowserLogPayload = {
46
+ level: 'log' | 'warn' | 'error' | 'info' | 'debug';
47
+ content: string;
48
+ taskId?: string;
49
+ taskName?: string;
50
+ taskParentNames?: string[];
51
+ taskType?: 'file' | 'suite' | 'case';
52
+ testPath: string;
53
+ type: 'stdout' | 'stderr';
54
+ trace?: string;
55
+ };
41
56
  export type BrowserHostConfig = {
42
57
  rootPath: string;
43
58
  projects: BrowserProjectRuntime[];
@@ -46,31 +61,25 @@ export type BrowserHostConfig = {
46
61
  };
47
62
  testFile?: string;
48
63
  /**
49
- * Per-run identifier assigned by the container.
50
- * Used by browser RPC calls to prevent stale requests from previous reruns.
51
- */
52
- runId?: string;
64
+ * Per-run identifier assigned by the container.
65
+ * Used by browser RPC calls to prevent stale requests from previous reruns.
66
+ */ runId?: string;
53
67
  /**
54
- * Base URL for runner (iframe) pages.
55
- */
56
- runnerUrl?: string;
68
+ * Base URL for runner (iframe) pages.
69
+ */ runnerUrl?: string;
57
70
  /**
58
- * WebSocket port for container RPC.
59
- */
60
- wsPort?: number;
71
+ * WebSocket port for container RPC.
72
+ */ wsPort?: number;
61
73
  /**
62
- * Execution mode. Defaults to 'run'.
63
- */
64
- mode?: BrowserExecutionMode;
74
+ * Execution mode. Defaults to 'run'.
75
+ */ mode?: BrowserExecutionMode;
65
76
  /**
66
- * Debug mode. When true, enables verbose logging in browser.
67
- */
68
- debug?: boolean;
77
+ * Debug mode. When true, enables verbose logging in browser.
78
+ */ debug?: boolean;
69
79
  /**
70
- * Timeout for RPC operations in milliseconds (e.g., snapshot file operations).
71
- * Derived from testTimeout config.
72
- */
73
- rpcTimeout?: number;
80
+ * Timeout for RPC operations in milliseconds (e.g., snapshot file operations).
81
+ * Derived from testTimeout config.
82
+ */ rpcTimeout?: number;
74
83
  };
75
84
  export type BrowserClientMessage = {
76
85
  type: 'ready';
@@ -88,17 +97,7 @@ export type BrowserClientMessage = {
88
97
  payload: TestFileResult;
89
98
  } | {
90
99
  type: 'log';
91
- payload: {
92
- level: 'log' | 'warn' | 'error' | 'info' | 'debug';
93
- content: string;
94
- taskId?: string;
95
- taskName?: string;
96
- taskParentNames?: string[];
97
- taskType?: 'file' | 'suite' | 'case';
98
- testPath: string;
99
- type: 'stdout' | 'stderr';
100
- trace?: string;
101
- };
100
+ payload: BrowserLogPayload;
102
101
  } | {
103
102
  type: 'fatal';
104
103
  payload: {
@@ -120,17 +119,42 @@ export type BrowserClientMessage = {
120
119
  type: typeof DISPATCH_RPC_REQUEST_TYPE;
121
120
  payload: BrowserDispatchRequest;
122
121
  };
122
+ /**
123
+ * Lifecycle methods the runner emits via `dispatchRunnerLifecycle()` as
124
+ * dispatch-rpc-requests on the `runner` namespace (as opposed to the
125
+ * {@link BrowserClientMessage} types it `send()`s). The runner client imports
126
+ * this instead of redeclaring the list, so the emit site cannot drift from the
127
+ * host router.
128
+ */ export type RunnerLifecycleMethod = 'file-ready' | 'suite-start' | 'suite-result' | 'case-start';
129
+ /**
130
+ * {@link BrowserClientMessage} types that are forwarded to the `runner`
131
+ * namespace (by message `type`) rather than handled at the transport layer.
132
+ * `Extract` keeps this a checked subset of the message union — renaming a
133
+ * message type drops it here, surfacing as a missing handler downstream.
134
+ */ type RunnerMessageMethod = Extract<BrowserClientMessage['type'], 'file-start' | 'case-result' | 'file-complete' | 'log' | 'fatal'>;
135
+ /**
136
+ * Single source of truth for every method handled by the `runner` dispatch
137
+ * namespace. The host handler table is keyed by this union (a missing key is a
138
+ * compile error), so adding a runner method here forces a matching handler and
139
+ * cannot silently no-op at runtime.
140
+ */ export type RunnerDispatchMethod = RunnerLifecycleMethod | RunnerMessageMethod;
123
141
  /**
124
142
  * Transport-agnostic envelope used by host routing.
125
143
  * `namespace + method + args + target` describes an operation independent of
126
144
  * the underlying message channel, and `runToken` provides run-level isolation.
127
- */
128
- export type BrowserDispatchRequest = {
145
+ */ export type BrowserDispatchRequest = {
129
146
  requestId: string;
147
+ // Optional so headed/container paths can adopt the same envelope even when
148
+ // run-token isolation is only enforced in headless scheduling today.
130
149
  runToken?: number;
131
150
  namespace: string;
132
151
  method: string;
133
152
  args?: unknown;
153
+ // Routing reads `namespace`, `method`, `runToken`, and `target.sessionId`
154
+ // (see dispatchRouter.ts / dispatchBrowserRpcRequest). `target.testFile` and
155
+ // `target.projectName` are carried for diagnostics / forward-compatibility and
156
+ // are NOT consulted for routing today — adding a routing-relevant field here
157
+ // means wiring a reader on the host side, which structural typing won't force.
134
158
  target?: {
135
159
  testFile?: string;
136
160
  sessionId?: string;
@@ -140,8 +164,7 @@ export type BrowserDispatchRequest = {
140
164
  /**
141
165
  * Dispatch response envelope.
142
166
  * `stale: true` signals a safe drop from an older run generation, not a failure.
143
- */
144
- export type BrowserDispatchResponse = {
167
+ */ export type BrowserDispatchResponse = {
145
168
  requestId: string;
146
169
  runToken?: number;
147
170
  result?: unknown;
@@ -1,3 +1,4 @@
1
+ import type { BrowserProvider } from '@rstest/core/internal/browser';
1
2
  import type { BrowserRpcRequest } from '../rpcProtocol.js';
2
3
  /**
3
4
  * Browser provider contract hub.
@@ -12,10 +13,14 @@ import type { BrowserRpcRequest } from '../rpcProtocol.js';
12
13
  * - do not reference optional peer provider types from public declarations
13
14
  * - keep provider-specific behavior and config decoding inside provider implementations
14
15
  * - prefer direct passthrough to provider APIs over provider-specific translation
15
- */
16
- export type BrowserProvider = 'playwright';
17
- /** Minimal console shape needed by host logging bridge. */
18
- export type BrowserConsoleMessage = {
16
+ *
17
+ * The provider-name union is owned by `@rstest/core` (see `BROWSER_PROVIDERS`)
18
+ * because core's CLI `init` templates need it but cannot import this package
19
+ * (peer-dependency direction). `providerImplementations` below is keyed by the
20
+ * re-exported union, so a provider added in core without an implementation here
21
+ * is a compile error.
22
+ */ export type { BrowserProvider };
23
+ /** Minimal console shape needed by host logging bridge. */ export type BrowserConsoleMessage = {
19
24
  text: () => string;
20
25
  };
21
26
  /**
@@ -27,29 +32,26 @@ export type BrowserConsoleMessage = {
27
32
  * (e.g. WebDriver BiDi), consider pushing page-level orchestration (goto,
28
33
  * exposeFunction, addInitScript, event listeners) into provider-specific
29
34
  * implementations so hostController only calls high-level semantic methods.
30
- */
31
- export type BrowserProviderPage = {
35
+ */ export type BrowserProviderPage = {
32
36
  goto: (url: string, options?: {
33
37
  waitUntil?: 'load';
34
38
  }) => Promise<unknown>;
35
39
  exposeFunction: (name: string, fn: (...args: any[]) => any) => Promise<void>;
36
40
  addInitScript: (script: string) => Promise<void>;
37
41
  on: {
38
- (event: 'popup', listener: (page: BrowserProviderPage) => void): void;
39
- (event: 'console', listener: (message: BrowserConsoleMessage) => void): void;
42
+ (event: 'popup', listener: (page: BrowserProviderPage) => void) : void;
43
+ (event: 'console', listener: (message: BrowserConsoleMessage) => void) : void;
40
44
  };
41
45
  close: () => Promise<void>;
42
46
  [Symbol.asyncDispose]: () => Promise<void>;
43
47
  };
44
- /** Minimal browser context API surface required by hostController. */
45
- export type BrowserProviderContext = {
48
+ /** Minimal browser context API surface required by hostController. */ export type BrowserProviderContext = {
46
49
  newPage: () => Promise<BrowserProviderPage>;
47
50
  on: (event: 'page', listener: (page: BrowserProviderPage) => void) => void;
48
51
  close: () => Promise<void>;
49
52
  [Symbol.asyncDispose]: () => Promise<void>;
50
53
  };
51
- /** Minimal browser API surface required by hostController. */
52
- export type BrowserProviderBrowser = {
54
+ /** Minimal browser API surface required by hostController. */ export type BrowserProviderBrowser = {
53
55
  close: () => Promise<void>;
54
56
  [Symbol.asyncDispose]: () => Promise<void>;
55
57
  newContext: (options: {
@@ -60,18 +62,15 @@ export type BrowserProviderBrowser = {
60
62
  providerOptions?: Record<string, unknown>;
61
63
  }) => Promise<BrowserProviderContext>;
62
64
  };
63
- /** Provider launch result consumed by hostController. */
64
- export type BrowserProviderRuntime = {
65
+ /** Provider launch result consumed by hostController. */ export type BrowserProviderRuntime = {
65
66
  browser: BrowserProviderBrowser;
66
67
  };
67
- /** Input contract for browser launch. */
68
- export type LaunchBrowserInput = {
68
+ /** Input contract for browser launch. */ export type LaunchBrowserInput = {
69
69
  browserName: 'chromium' | 'firefox' | 'webkit';
70
70
  headless: boolean | undefined;
71
71
  providerOptions: Record<string, unknown>;
72
72
  };
73
- /** Input contract for provider-side browser RPC dispatch. */
74
- export type DispatchBrowserRpcInput = {
73
+ /** Input contract for provider-side browser RPC dispatch. */ export type DispatchBrowserRpcInput = {
75
74
  containerPage?: BrowserProviderPage;
76
75
  runnerPage?: BrowserProviderPage;
77
76
  request: BrowserRpcRequest;
@@ -83,8 +82,7 @@ export type DispatchBrowserRpcInput = {
83
82
  * Any new built-in provider must:
84
83
  * - launch browser runtime for test execution
85
84
  * - execute browser RPC requests (locator actions + assertions)
86
- */
87
- export type BrowserProviderImplementation = {
85
+ */ export type BrowserProviderImplementation = {
88
86
  name: BrowserProvider;
89
87
  launchRuntime: (input: LaunchBrowserInput) => Promise<BrowserProviderRuntime>;
90
88
  dispatchRpc: (input: DispatchBrowserRpcInput) => Promise<unknown>;
@@ -2,10 +2,12 @@
2
2
  * Contains adapted logic from Playwright matchers:
3
3
  * https://github.com/microsoft/playwright/blob/main/packages/playwright/src/matchers/matchers.ts
4
4
  * Copyright (c) Microsoft Corporation, Apache-2.0.
5
- */
6
- import type { Page } from 'playwright';
5
+ */ import type { Page } from 'playwright';
7
6
  import type { BrowserRpcRequest } from '../../rpcProtocol.js';
8
- export declare function dispatchPlaywrightBrowserRpc({ containerPage, runnerPage, request, timeoutFallbackMs, }: {
7
+ // ---------------------------------------------------------------------------
8
+ // Public entry
9
+ // ---------------------------------------------------------------------------
10
+ export declare function dispatchPlaywrightBrowserRpc({ containerPage, runnerPage, request, timeoutFallbackMs }: {
9
11
  containerPage?: Page;
10
12
  runnerPage?: Page;
11
13
  request: BrowserRpcRequest;
@@ -2,8 +2,7 @@
2
2
  * Contains adapted logic from Playwright matchers:
3
3
  * https://github.com/microsoft/playwright/blob/main/packages/playwright/src/matchers/matchers.ts
4
4
  * Copyright (c) Microsoft Corporation, Apache-2.0.
5
- */
6
- import type { BrowserLocatorText } from '../../rpcProtocol.js';
5
+ */ import type { BrowserLocatorText } from '../../rpcProtocol.js';
7
6
  type ExpectedTextValue = {
8
7
  string?: string;
9
8
  regexSource?: string;
@@ -21,4 +20,4 @@ export declare const formatExpectError: (result: {
21
20
  errorMessage?: string;
22
21
  log?: string[];
23
22
  }) => string;
24
- export {};
23
+ export { };
@@ -1,2 +1,2 @@
1
- import type { BrowserProviderImplementation } from '../index.js';
1
+ import type { BrowserProviderImplementation, BrowserProviderRuntime } from '../index.js';
2
2
  export declare const playwrightProviderImplementation: BrowserProviderImplementation;
@@ -1,5 +1,5 @@
1
1
  import type { BrowserProviderRuntime } from '../index.js';
2
- export declare function launchPlaywrightBrowser({ browserName, headless, providerOptions, }: {
2
+ export declare function launchPlaywrightBrowser({ browserName, headless, providerOptions }: {
3
3
  browserName: 'chromium' | 'firefox' | 'webkit';
4
4
  headless: boolean | undefined;
5
5
  providerOptions: Record<string, unknown>;
@@ -83,50 +83,57 @@ export type BrowserLocatorIR = {
83
83
  };
84
84
  export type BrowserRpcRequest = {
85
85
  id: string;
86
- /** Absolute test file path for locating runner iframe */
87
- testPath: string;
88
- /** Run identifier generated by container for stale-request protection. */
89
- runId: string;
86
+ /** Absolute test file path for locating runner iframe */ testPath: string;
87
+ /** Run identifier generated by container for stale-request protection. */ runId: string;
90
88
  kind: 'locator' | 'expect' | 'config';
91
89
  locator: BrowserLocatorIR;
92
90
  method: string;
93
91
  args: unknown[];
94
92
  /**
95
- * Negation for expect matchers (equivalent to Playwright expect(...).not).
96
- * Only meaningful for kind === 'expect'.
97
- */
98
- isNot?: boolean;
99
- /** Optional timeout override (ms). Falls back to browser rpcTimeout. */
100
- timeout?: number;
93
+ * Negation for expect matchers (equivalent to Playwright expect(...).not).
94
+ * Only meaningful for kind === 'expect'.
95
+ */ isNot?: boolean;
96
+ /** Optional timeout override (ms). Falls back to browser rpcTimeout. */ timeout?: number;
101
97
  };
102
98
  export declare const validateBrowserRpcRequest: (payload: unknown) => BrowserRpcRequest;
103
99
  /**
104
- * Snapshot RPC request from runner iframe.
105
- * The container will forward these to the host via WebSocket RPC.
106
- */
107
- export type SnapshotRpcRequest = {
108
- id: string;
109
- method: 'resolveSnapshotPath';
110
- args: {
100
+ * Single source of truth for snapshot RPC methods and their argument shapes.
101
+ * The request union, the client sender, both host-side mappers, and every
102
+ * exhaustiveness check derive from this map — adding or renaming a method here
103
+ * forces a compile error at every site that has not been updated.
104
+ */ export type SnapshotRpcMethodArgs = {
105
+ resolveSnapshotPath: {
111
106
  testPath: string;
112
107
  };
113
- } | {
114
- id: string;
115
- method: 'readSnapshotFile';
116
- args: {
108
+ readSnapshotFile: {
117
109
  filepath: string;
118
110
  };
119
- } | {
120
- id: string;
121
- method: 'saveSnapshotFile';
122
- args: {
111
+ saveSnapshotFile: {
123
112
  filepath: string;
124
113
  content: string;
125
114
  };
126
- } | {
127
- id: string;
128
- method: 'removeSnapshotFile';
129
- args: {
115
+ removeSnapshotFile: {
130
116
  filepath: string;
131
117
  };
132
118
  };
119
+ export type SnapshotRpcMethod = keyof SnapshotRpcMethodArgs;
120
+ /**
121
+ * Snapshot RPC request from runner iframe.
122
+ * The container will forward these to the host via WebSocket RPC.
123
+ */ export type SnapshotRpcRequest = {
124
+ [M in SnapshotRpcMethod]: {
125
+ id: string;
126
+ method: M;
127
+ args: SnapshotRpcMethodArgs[M];
128
+ };
129
+ }[SnapshotRpcMethod];
130
+ /**
131
+ * Client-side snapshot RPC call (request without the transport `id`).
132
+ * Distributive over {@link SnapshotRpcMethod} so `method` and `args` stay paired
133
+ * at the call site — a mismatched pair fails to compile.
134
+ */ export type SnapshotRpcCall = {
135
+ [M in SnapshotRpcMethod]: {
136
+ method: M;
137
+ args: SnapshotRpcMethodArgs[M];
138
+ };
139
+ }[SnapshotRpcMethod];
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Run generation/session lifecycle contract shared by browser scheduling paths.
3
- */
4
- export type RunSession = {
3
+ */ export type RunSession = {
5
4
  token: number;
6
5
  cancelled: boolean;
7
6
  cancelSignal: Promise<void>;
@@ -16,8 +15,7 @@ type CancelOptions<T extends RunSession> = {
16
15
  /**
17
16
  * Canonical run-token lifecycle manager.
18
17
  * Centralizes token increment, invalidation, and cancellation semantics.
19
- */
20
- export declare class RunSessionLifecycle<T extends RunSession> {
18
+ */ export declare class RunSessionLifecycle<T extends RunSession> {
21
19
  private currentToken;
22
20
  private active;
23
21
  get activeSession(): T | null;
@@ -30,4 +28,4 @@ export declare class RunSessionLifecycle<T extends RunSession> {
30
28
  cancel(session: T, options?: CancelOptions<T>): Promise<void>;
31
29
  cancelActive(options?: CancelOptions<T>): Promise<void>;
32
30
  }
33
- export {};
31
+ export { };
@@ -17,8 +17,7 @@ type RunnerSessionInput = Omit<RunnerSessionRecord, 'id' | 'createdAt'> & {
17
17
  /**
18
18
  * Execution target index for host scheduling.
19
19
  * Provides lookup by session id, test file, and run token without coupling to UI topology.
20
- */
21
- export declare class RunnerSessionRegistry {
20
+ */ export declare class RunnerSessionRegistry {
22
21
  private nextId;
23
22
  private sessionsById;
24
23
  private sessionIdByTestFile;
@@ -31,4 +30,4 @@ export declare class RunnerSessionRegistry {
31
30
  deleteByTestFile(testFile: string): boolean;
32
31
  clear(): void;
33
32
  }
34
- export {};
33
+ export { };
@@ -4,11 +4,11 @@ type Fetcher = typeof fetch;
4
4
  export declare const normalizeJavaScriptUrl: (value: string, options?: {
5
5
  origin?: string;
6
6
  }) => string | null;
7
- export declare const loadSourceMapWithCache: ({ jsUrl, cache, force, origin, fetcher, }: {
7
+ export declare const loadSourceMapWithCache: ({ jsUrl, cache, force, origin, fetcher }: {
8
8
  jsUrl: string;
9
9
  cache: Map<string, SourceMapPayload | null>;
10
10
  force?: boolean;
11
11
  origin?: string;
12
12
  fetcher?: Fetcher;
13
13
  }) => Promise<SourceMapPayload | null>;
14
- export {};
14
+ export { };
@@ -4,8 +4,12 @@
4
4
  * IMPORTANT: Keep this list/map in sync with `DevicePreset` typing in
5
5
  * `@rstest/core` (`packages/core/src/types/config.ts`) so `defineConfig`
6
6
  * autocomplete and runtime validation stay consistent.
7
- */
8
- export declare const BROWSER_VIEWPORT_PRESET_IDS: readonly ['iPhoneSE', 'iPhoneXR', 'iPhone12Pro', 'iPhone14ProMax', 'Pixel7', 'SamsungGalaxyS8Plus', 'SamsungGalaxyS20Ultra', 'iPadMini', 'iPadAir', 'iPadPro', 'SurfacePro7', 'SurfaceDuo', 'GalaxyZFold5', 'AsusZenbookFold', 'SamsungGalaxyA51A71', 'NestHub', 'NestHubMax'];
7
+ *
8
+ * Upstream source of truth for ids/dimensions is the Chrome DevTools emulated
9
+ * device list — mirror each device's `screen.vertical` `{ width, height }`:
10
+ * https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/models/emulation/EmulatedDevices.ts
11
+ * Last verified in sync (all 17): 2026-04-22, devtools-frontend commit abaac05e.
12
+ */ export declare const BROWSER_VIEWPORT_PRESET_IDS: readonly ['iPhoneSE', 'iPhoneXR', 'iPhone12Pro', 'iPhone14ProMax', 'Pixel7', 'SamsungGalaxyS8Plus', 'SamsungGalaxyS20Ultra', 'iPadMini', 'iPadAir', 'iPadPro', 'SurfacePro7', 'SurfaceDuo', 'GalaxyZFold5', 'AsusZenbookFold', 'SamsungGalaxyA51A71', 'NestHub', 'NestHubMax'];
9
13
  type BrowserViewportPresetId = (typeof BROWSER_VIEWPORT_PRESET_IDS)[number];
10
14
  type BrowserViewportSize = {
11
15
  width: number;
@@ -13,4 +17,4 @@ type BrowserViewportSize = {
13
17
  };
14
18
  export declare const BROWSER_VIEWPORT_PRESET_DIMENSIONS: Record<BrowserViewportPresetId, BrowserViewportSize>;
15
19
  export declare const resolveBrowserViewportPreset: (presetId: string) => BrowserViewportSize | null;
16
- export {};
20
+ export { };
@@ -1,6 +1,6 @@
1
1
  export declare const isBrowserWatchCliShortcutsEnabled: () => boolean;
2
2
  export declare const getBrowserWatchCliShortcutsHintMessage: () => string;
3
3
  export declare const logBrowserWatchReadyMessage: (enableCliShortcuts: boolean) => void;
4
- export declare function setupBrowserWatchCliShortcuts({ close, }: {
4
+ export declare function setupBrowserWatchCliShortcuts({ close }: {
5
5
  close: () => Promise<void>;
6
6
  }): Promise<() => void>;
@@ -17,5 +17,5 @@ type WatchRerunPlan = {
17
17
  affectedTestFiles: TestFileInfo[];
18
18
  };
19
19
  export declare const collectWatchTestFiles: (projectEntries: WatchPlannerProjectEntry[]) => TestFileInfo[];
20
- export declare const planWatchRerun: ({ projectEntries, previousTestFiles, affectedTestFiles, }: WatchRerunPlannerInput) => WatchRerunPlan;
21
- export {};
20
+ export declare const planWatchRerun: ({ projectEntries, previousTestFiles, affectedTestFiles }: WatchRerunPlannerInput) => WatchRerunPlan;
21
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/browser",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "Browser mode support for Rstest testing framework.",
5
5
  "keywords": [
6
6
  "rstest",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://github.com/web-infra-dev/rstest",
17
+ "url": "git+https://github.com/web-infra-dev/rstest.git",
18
18
  "directory": "packages/browser"
19
19
  },
20
20
  "license": "MIT",
@@ -48,22 +48,21 @@
48
48
  "ws": "^8.21.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@rslib/core": "0.21.5",
51
+ "@rslib/core": "0.22.1",
52
52
  "@types/convert-source-map": "^2.0.3",
53
53
  "@types/picomatch": "^4.0.3",
54
54
  "@types/ws": "^8.18.1",
55
- "@typescript/native-preview": "7.0.0-dev.20260527.1",
56
- "@vitest/snapshot": "^3.2.4",
55
+ "@vitest/snapshot": "^3.2.6",
57
56
  "birpc": "^4.0.0",
58
57
  "picomatch": "^4.0.4",
59
58
  "playwright": "^1.60.0",
60
59
  "@rstest/browser-ui": "0.0.0",
61
- "@rstest/core": "0.10.3",
60
+ "@rstest/core": "0.10.5",
62
61
  "@rstest/tsconfig": "0.0.1"
63
62
  },
64
63
  "peerDependencies": {
65
64
  "playwright": "^1.49.1",
66
- "@rstest/core": "^0.10.3"
65
+ "@rstest/core": "^0.10.5"
67
66
  },
68
67
  "peerDependenciesMeta": {
69
68
  "playwright": {
@@ -79,7 +78,6 @@
79
78
  },
80
79
  "scripts": {
81
80
  "build": "rslib build",
82
- "dev": "rslib build --watch",
83
- "typecheck": "pnpm -w exec tsc --noEmit -p packages/browser/tsconfig.json"
81
+ "dev": "rslib build --watch"
84
82
  }
85
83
  }
package/src/AGENTS.md CHANGED
@@ -15,6 +15,9 @@ flowchart LR
15
15
  SR["sessionRegistry.ts\nRunnerSessionRegistry"]
16
16
  WP["watchRerunPlanner.ts"]
17
17
  LS["headlessLatestRerunScheduler.ts"]
18
+ HT["headlessTransport.ts\nattachHeadlessRunnerTransport()"]
19
+ CC["concurrency.ts\ngetHeadlessConcurrency()"]
20
+ HQ["headedSerialTaskQueue.ts\ncreateHeadedSerialTaskQueue()"]
18
21
  end
19
22
 
20
23
  subgraph UI["@rstest/browser-ui container (headed path)"]
@@ -35,6 +38,9 @@ flowchart LR
35
38
  WP --> LS
36
39
  HC --> RL
37
40
  RL --> SR
41
+ HC --> CC
42
+ HC --> HQ
43
+ HC --> HT
38
44
 
39
45
  UR <--> HC
40
46
  MSG --> MH
@@ -42,7 +48,7 @@ flowchart LR
42
48
  RPC --> CH
43
49
  CH --> UR
44
50
 
45
- HC -."headless bridge:\nexposeFunction(__rstest_dispatch__, __rstest_dispatch_rpc__)".-> Runner
51
+ HT -."headless bridge:\nexposeFunction(__rstest_dispatch__, __rstest_dispatch_rpc__)".-> Runner
46
52
  ```
47
53
 
48
54
  ## Headed transport path
@@ -14,7 +14,7 @@
14
14
  * - Artifacts intentionally excluded for now: screenshot/toMatchScreenshot/
15
15
  * trace/video
16
16
  */
17
- export const supportedLocatorActions = new Set<string>([
17
+ export const supportedLocatorActions: Set<string> = new Set([
18
18
  'click',
19
19
  'dblclick',
20
20
  'fill',
@@ -32,7 +32,7 @@ export const supportedLocatorActions = new Set<string>([
32
32
  'setInputFiles',
33
33
  ]);
34
34
 
35
- export const supportedExpectElementMatchers = new Set<string>([
35
+ export const supportedExpectElementMatchers: Set<string> = new Set([
36
36
  'toBeVisible',
37
37
  'toBeHidden',
38
38
  'toBeEnabled',