@rstest/browser 0.8.4 → 0.9.0
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/LICENSE-APACHE-2.0 +202 -0
- package/NOTICE +11 -0
- package/dist/361.js +8 -0
- package/dist/augmentExpect.d.ts +73 -0
- package/dist/browser-container/container-static/css/index.5c72297783.css +1 -0
- package/dist/browser-container/container-static/js/{392.28f9a733.js → 101.36a8ccdf84.js} +4068 -3904
- package/dist/browser-container/container-static/js/101.36a8ccdf84.js.LICENSE.txt +1 -0
- package/dist/browser-container/container-static/js/{index.129eaf9c.js → index.0687a8142a.js} +742 -692
- package/dist/browser-container/container-static/js/{lib-react.97ee79b0.js → lib-react.dcf2a5e57a.js} +10 -10
- package/dist/browser-container/container-static/js/lib-react.dcf2a5e57a.js.LICENSE.txt +1 -0
- package/dist/browser-container/index.html +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +583 -0
- package/dist/browserRpcRegistry.d.ts +18 -0
- package/dist/client/api.d.ts +3 -0
- package/dist/client/browserRpc.d.ts +2 -0
- package/dist/client/dispatchTransport.d.ts +11 -0
- package/dist/client/entry.d.ts +1 -5
- package/dist/client/locator.d.ts +125 -0
- package/dist/client/snapshot.d.ts +0 -6
- package/dist/concurrency.d.ts +12 -0
- package/dist/dispatchCapabilities.d.ts +34 -0
- package/dist/dispatchRouter.d.ts +20 -0
- package/dist/headlessLatestRerunScheduler.d.ts +19 -0
- package/dist/headlessTransport.d.ts +12 -0
- package/dist/index.js +1608 -296
- package/dist/protocol.d.ts +44 -33
- package/dist/providers/index.d.ts +79 -0
- package/dist/providers/playwright/compileLocator.d.ts +3 -0
- package/dist/providers/playwright/dispatchBrowserRpc.d.ts +13 -0
- package/dist/providers/playwright/expectUtils.d.ts +24 -0
- package/dist/providers/playwright/implementation.d.ts +2 -0
- package/dist/providers/playwright/index.d.ts +1 -0
- package/dist/providers/playwright/runtime.d.ts +5 -0
- package/dist/providers/playwright/textMatcher.d.ts +8 -0
- package/dist/rpcProtocol.d.ts +145 -0
- package/dist/runSession.d.ts +33 -0
- package/dist/sessionRegistry.d.ts +34 -0
- package/dist/sourceMap/sourceMapLoader.d.ts +14 -0
- package/dist/watchRerunPlanner.d.ts +21 -0
- package/package.json +16 -11
- package/src/AGENTS.md +128 -0
- package/src/augmentExpect.ts +62 -0
- package/src/browser.ts +3 -0
- package/src/browserRpcRegistry.ts +57 -0
- package/src/client/AGENTS.md +82 -0
- package/src/client/api.ts +213 -0
- package/src/client/browserRpc.ts +86 -0
- package/src/client/dispatchTransport.ts +178 -0
- package/src/client/entry.ts +109 -39
- package/src/client/locator.ts +452 -0
- package/src/client/snapshot.ts +32 -97
- package/src/client/sourceMapSupport.ts +26 -37
- package/src/concurrency.ts +62 -0
- package/src/dispatchCapabilities.ts +162 -0
- package/src/dispatchRouter.ts +82 -0
- package/src/env.d.ts +8 -1
- package/src/headlessLatestRerunScheduler.ts +76 -0
- package/src/headlessTransport.ts +28 -0
- package/src/hostController.ts +1292 -367
- package/src/protocol.ts +66 -31
- package/src/providers/index.ts +103 -0
- package/src/providers/playwright/compileLocator.ts +130 -0
- package/src/providers/playwright/dispatchBrowserRpc.ts +372 -0
- package/src/providers/playwright/expectUtils.ts +57 -0
- package/src/providers/playwright/implementation.ts +33 -0
- package/src/providers/playwright/index.ts +1 -0
- package/src/providers/playwright/runtime.ts +32 -0
- package/src/providers/playwright/textMatcher.ts +10 -0
- package/src/rpcProtocol.ts +220 -0
- package/src/runSession.ts +110 -0
- package/src/sessionRegistry.ts +89 -0
- package/src/sourceMap/sourceMapLoader.ts +96 -0
- package/src/watchRerunPlanner.ts +77 -0
- package/dist/browser-container/container-static/css/index.5a71c757.css +0 -1
- package/dist/browser-container/container-static/js/392.28f9a733.js.LICENSE.txt +0 -1
- package/dist/browser-container/container-static/js/lib-react.97ee79b0.js.LICENSE.txt +0 -1
- package/dist/browser-container/container-static/js/scheduler.6976de44.js +0 -411
- package/dist/browser-container/scheduler.html +0 -19
package/dist/protocol.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { DevicePreset } from '@rstest/core/browser';
|
|
2
|
-
import type { RuntimeConfig,
|
|
2
|
+
import type { RuntimeConfig, TestFileResult, TestInfo, TestResult } from '@rstest/core/browser-runtime';
|
|
3
3
|
import type { SnapshotUpdateState } from '@vitest/snapshot';
|
|
4
|
+
export type { BrowserLocatorIR, BrowserLocatorStep, BrowserLocatorText, BrowserRpcRequest, BrowserRpcResponse, SnapshotRpcRequest, SnapshotRpcResponse, } from './rpcProtocol';
|
|
5
|
+
export { validateBrowserRpcRequest } from './rpcProtocol';
|
|
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";
|
|
4
15
|
export type SerializedRuntimeConfig = RuntimeConfig;
|
|
5
16
|
export type BrowserViewport = {
|
|
6
17
|
width: number;
|
|
@@ -34,6 +45,11 @@ export type BrowserHostConfig = {
|
|
|
34
45
|
updateSnapshot: SnapshotUpdateState;
|
|
35
46
|
};
|
|
36
47
|
testFile?: string;
|
|
48
|
+
/**
|
|
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;
|
|
37
53
|
/**
|
|
38
54
|
* Base URL for runner (iframe) pages.
|
|
39
55
|
*/
|
|
@@ -92,49 +108,44 @@ export type BrowserClientMessage = {
|
|
|
92
108
|
payload: {
|
|
93
109
|
testPath: string;
|
|
94
110
|
project: string;
|
|
95
|
-
tests:
|
|
111
|
+
tests: TestInfo[];
|
|
96
112
|
};
|
|
97
113
|
} | {
|
|
98
114
|
type: 'collect-complete';
|
|
99
115
|
} | {
|
|
100
|
-
type:
|
|
101
|
-
payload:
|
|
116
|
+
type: typeof DISPATCH_RPC_REQUEST_TYPE;
|
|
117
|
+
payload: BrowserDispatchRequest;
|
|
102
118
|
};
|
|
103
119
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
120
|
+
* Transport-agnostic envelope used by host routing.
|
|
121
|
+
* `namespace + method + args + target` describes an operation independent of
|
|
122
|
+
* the underlying message channel, and `runToken` provides run-level isolation.
|
|
106
123
|
*/
|
|
107
|
-
export type
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
filepath: string;
|
|
118
|
-
};
|
|
119
|
-
} | {
|
|
120
|
-
id: string;
|
|
121
|
-
method: 'saveSnapshotFile';
|
|
122
|
-
args: {
|
|
123
|
-
filepath: string;
|
|
124
|
-
content: string;
|
|
125
|
-
};
|
|
126
|
-
} | {
|
|
127
|
-
id: string;
|
|
128
|
-
method: 'removeSnapshotFile';
|
|
129
|
-
args: {
|
|
130
|
-
filepath: string;
|
|
124
|
+
export type BrowserDispatchRequest = {
|
|
125
|
+
requestId: string;
|
|
126
|
+
runToken?: number;
|
|
127
|
+
namespace: string;
|
|
128
|
+
method: string;
|
|
129
|
+
args?: unknown;
|
|
130
|
+
target?: {
|
|
131
|
+
testFile?: string;
|
|
132
|
+
sessionId?: string;
|
|
133
|
+
projectName?: string;
|
|
131
134
|
};
|
|
132
135
|
};
|
|
133
136
|
/**
|
|
134
|
-
*
|
|
137
|
+
* Dispatch response envelope.
|
|
138
|
+
* `stale: true` signals a safe drop from an older run generation, not a failure.
|
|
135
139
|
*/
|
|
136
|
-
export type
|
|
137
|
-
|
|
140
|
+
export type BrowserDispatchResponse = {
|
|
141
|
+
requestId: string;
|
|
142
|
+
runToken?: number;
|
|
138
143
|
result?: unknown;
|
|
139
144
|
error?: string;
|
|
145
|
+
stale?: boolean;
|
|
146
|
+
};
|
|
147
|
+
export type BrowserDispatchResponseEnvelope = {
|
|
148
|
+
type: typeof DISPATCH_RESPONSE_TYPE;
|
|
149
|
+
payload: BrowserDispatchResponse;
|
|
140
150
|
};
|
|
151
|
+
export type BrowserDispatchHandler = (request: BrowserDispatchRequest) => Promise<unknown>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { BrowserRpcRequest } from '../rpcProtocol';
|
|
2
|
+
/**
|
|
3
|
+
* Browser provider contract hub.
|
|
4
|
+
*
|
|
5
|
+
* When adding a new built-in provider, implement `BrowserProviderImplementation`
|
|
6
|
+
* and register it in `providerImplementations` below.
|
|
7
|
+
*/
|
|
8
|
+
export type BrowserProvider = 'playwright';
|
|
9
|
+
/** Minimal console shape needed by host logging bridge. */
|
|
10
|
+
export type BrowserConsoleMessage = {
|
|
11
|
+
text: () => string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Minimal page API surface required by hostController.
|
|
15
|
+
*
|
|
16
|
+
* This is a structural type (shape interface), NOT a direct Playwright import.
|
|
17
|
+
* It currently mirrors a subset of Playwright's Page API because that is the
|
|
18
|
+
* only provider. When adding a second provider whose page primitive diverges
|
|
19
|
+
* (e.g. WebDriver BiDi), consider pushing page-level orchestration (goto,
|
|
20
|
+
* exposeFunction, addInitScript, event listeners) into provider-specific
|
|
21
|
+
* implementations so hostController only calls high-level semantic methods.
|
|
22
|
+
*/
|
|
23
|
+
export type BrowserProviderPage = {
|
|
24
|
+
goto: (url: string, options?: {
|
|
25
|
+
waitUntil?: 'load';
|
|
26
|
+
}) => Promise<unknown>;
|
|
27
|
+
exposeFunction: (name: string, fn: (...args: any[]) => any) => Promise<void>;
|
|
28
|
+
addInitScript: (script: string) => Promise<void>;
|
|
29
|
+
on: {
|
|
30
|
+
(event: 'popup', listener: (page: BrowserProviderPage) => void): void;
|
|
31
|
+
(event: 'console', listener: (message: BrowserConsoleMessage) => void): void;
|
|
32
|
+
};
|
|
33
|
+
close: () => Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
/** Minimal browser context API surface required by hostController. */
|
|
36
|
+
export type BrowserProviderContext = {
|
|
37
|
+
newPage: () => Promise<BrowserProviderPage>;
|
|
38
|
+
on: (event: 'page', listener: (page: BrowserProviderPage) => void) => void;
|
|
39
|
+
close: () => Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
/** Minimal browser API surface required by hostController. */
|
|
42
|
+
export type BrowserProviderBrowser = {
|
|
43
|
+
close: () => Promise<void>;
|
|
44
|
+
newContext: (options: {
|
|
45
|
+
viewport: {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
} | null;
|
|
49
|
+
}) => Promise<BrowserProviderContext>;
|
|
50
|
+
};
|
|
51
|
+
/** Provider launch result consumed by hostController. */
|
|
52
|
+
export type BrowserProviderRuntime = {
|
|
53
|
+
browser: BrowserProviderBrowser;
|
|
54
|
+
};
|
|
55
|
+
/** Input contract for browser launch. */
|
|
56
|
+
export type LaunchBrowserInput = {
|
|
57
|
+
browserName: 'chromium' | 'firefox' | 'webkit';
|
|
58
|
+
headless: boolean | undefined;
|
|
59
|
+
};
|
|
60
|
+
/** Input contract for provider-side browser RPC dispatch. */
|
|
61
|
+
export type DispatchBrowserRpcInput = {
|
|
62
|
+
containerPage?: BrowserProviderPage;
|
|
63
|
+
runnerPage?: BrowserProviderPage;
|
|
64
|
+
request: BrowserRpcRequest;
|
|
65
|
+
timeoutFallbackMs: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Core provider implementation contract.
|
|
69
|
+
*
|
|
70
|
+
* Any new built-in provider must:
|
|
71
|
+
* - launch browser runtime for test execution
|
|
72
|
+
* - execute browser RPC requests (locator actions + assertions)
|
|
73
|
+
*/
|
|
74
|
+
export type BrowserProviderImplementation = {
|
|
75
|
+
name: BrowserProvider;
|
|
76
|
+
launchRuntime: (input: LaunchBrowserInput) => Promise<BrowserProviderRuntime>;
|
|
77
|
+
dispatchRpc: (input: DispatchBrowserRpcInput) => Promise<unknown>;
|
|
78
|
+
};
|
|
79
|
+
export declare function getBrowserProviderImplementation(provider: BrowserProvider): BrowserProviderImplementation;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains adapted logic from Playwright matchers:
|
|
3
|
+
* https://github.com/microsoft/playwright/blob/main/packages/playwright/src/matchers/matchers.ts
|
|
4
|
+
* Copyright (c) Microsoft Corporation, Apache-2.0.
|
|
5
|
+
*/
|
|
6
|
+
import type { Page } from 'playwright';
|
|
7
|
+
import type { BrowserRpcRequest } from '../../rpcProtocol';
|
|
8
|
+
export declare function dispatchPlaywrightBrowserRpc({ containerPage, runnerPage, request, timeoutFallbackMs, }: {
|
|
9
|
+
containerPage?: Page;
|
|
10
|
+
runnerPage?: Page;
|
|
11
|
+
request: BrowserRpcRequest;
|
|
12
|
+
timeoutFallbackMs: number;
|
|
13
|
+
}): Promise<unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains adapted logic from Playwright matchers:
|
|
3
|
+
* https://github.com/microsoft/playwright/blob/main/packages/playwright/src/matchers/matchers.ts
|
|
4
|
+
* Copyright (c) Microsoft Corporation, Apache-2.0.
|
|
5
|
+
*/
|
|
6
|
+
import type { BrowserLocatorText } from '../../rpcProtocol';
|
|
7
|
+
type ExpectedTextValue = {
|
|
8
|
+
string?: string;
|
|
9
|
+
regexSource?: string;
|
|
10
|
+
regexFlags?: string;
|
|
11
|
+
matchSubstring?: boolean;
|
|
12
|
+
ignoreCase?: boolean;
|
|
13
|
+
normalizeWhiteSpace?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const serializeExpectedText: (text: BrowserLocatorText, options?: {
|
|
16
|
+
matchSubstring?: boolean;
|
|
17
|
+
normalizeWhiteSpace?: boolean;
|
|
18
|
+
ignoreCase?: boolean;
|
|
19
|
+
}) => ExpectedTextValue[];
|
|
20
|
+
export declare const formatExpectError: (result: {
|
|
21
|
+
errorMessage?: string;
|
|
22
|
+
log?: string[];
|
|
23
|
+
}) => string;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { playwrightProviderImplementation } from './implementation';
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export type BrowserLocatorText = {
|
|
2
|
+
type: 'string';
|
|
3
|
+
value: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: 'regexp';
|
|
6
|
+
source: string;
|
|
7
|
+
flags?: string;
|
|
8
|
+
};
|
|
9
|
+
export type BrowserLocatorStep = {
|
|
10
|
+
type: 'getByRole';
|
|
11
|
+
role: string;
|
|
12
|
+
options?: {
|
|
13
|
+
name?: BrowserLocatorText;
|
|
14
|
+
exact?: boolean;
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
expanded?: boolean;
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
pressed?: boolean;
|
|
20
|
+
includeHidden?: boolean;
|
|
21
|
+
level?: number;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
type: 'locator';
|
|
25
|
+
selector: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'getByText';
|
|
28
|
+
text: BrowserLocatorText;
|
|
29
|
+
options?: {
|
|
30
|
+
exact?: boolean;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
type: 'getByLabel';
|
|
34
|
+
text: BrowserLocatorText;
|
|
35
|
+
options?: {
|
|
36
|
+
exact?: boolean;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
type: 'getByPlaceholder';
|
|
40
|
+
text: BrowserLocatorText;
|
|
41
|
+
options?: {
|
|
42
|
+
exact?: boolean;
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
type: 'getByAltText';
|
|
46
|
+
text: BrowserLocatorText;
|
|
47
|
+
options?: {
|
|
48
|
+
exact?: boolean;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
type: 'getByTitle';
|
|
52
|
+
text: BrowserLocatorText;
|
|
53
|
+
options?: {
|
|
54
|
+
exact?: boolean;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
type: 'getByTestId';
|
|
58
|
+
text: BrowserLocatorText;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'filter';
|
|
61
|
+
options: {
|
|
62
|
+
hasText?: BrowserLocatorText;
|
|
63
|
+
hasNotText?: BrowserLocatorText;
|
|
64
|
+
has?: BrowserLocatorIR;
|
|
65
|
+
hasNot?: BrowserLocatorIR;
|
|
66
|
+
};
|
|
67
|
+
} | {
|
|
68
|
+
type: 'and';
|
|
69
|
+
locator: BrowserLocatorIR;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'or';
|
|
72
|
+
locator: BrowserLocatorIR;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'nth';
|
|
75
|
+
index: number;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'first';
|
|
78
|
+
} | {
|
|
79
|
+
type: 'last';
|
|
80
|
+
};
|
|
81
|
+
export type BrowserLocatorIR = {
|
|
82
|
+
steps: BrowserLocatorStep[];
|
|
83
|
+
};
|
|
84
|
+
export type BrowserRpcRequest = {
|
|
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;
|
|
90
|
+
kind: 'locator' | 'expect' | 'config';
|
|
91
|
+
locator: BrowserLocatorIR;
|
|
92
|
+
method: string;
|
|
93
|
+
args: unknown[];
|
|
94
|
+
/**
|
|
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;
|
|
101
|
+
};
|
|
102
|
+
export declare const validateBrowserRpcRequest: (payload: unknown) => BrowserRpcRequest;
|
|
103
|
+
export type BrowserRpcResponse = {
|
|
104
|
+
id: string;
|
|
105
|
+
result?: unknown;
|
|
106
|
+
error?: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Snapshot RPC request from runner iframe.
|
|
110
|
+
* The container will forward these to the host via WebSocket RPC.
|
|
111
|
+
*/
|
|
112
|
+
export type SnapshotRpcRequest = {
|
|
113
|
+
id: string;
|
|
114
|
+
method: 'resolveSnapshotPath';
|
|
115
|
+
args: {
|
|
116
|
+
testPath: string;
|
|
117
|
+
};
|
|
118
|
+
} | {
|
|
119
|
+
id: string;
|
|
120
|
+
method: 'readSnapshotFile';
|
|
121
|
+
args: {
|
|
122
|
+
filepath: string;
|
|
123
|
+
};
|
|
124
|
+
} | {
|
|
125
|
+
id: string;
|
|
126
|
+
method: 'saveSnapshotFile';
|
|
127
|
+
args: {
|
|
128
|
+
filepath: string;
|
|
129
|
+
content: string;
|
|
130
|
+
};
|
|
131
|
+
} | {
|
|
132
|
+
id: string;
|
|
133
|
+
method: 'removeSnapshotFile';
|
|
134
|
+
args: {
|
|
135
|
+
filepath: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Snapshot RPC response from container to runner iframe.
|
|
140
|
+
*/
|
|
141
|
+
export type SnapshotRpcResponse = {
|
|
142
|
+
id: string;
|
|
143
|
+
result?: unknown;
|
|
144
|
+
error?: string;
|
|
145
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run generation/session lifecycle contract shared by browser scheduling paths.
|
|
3
|
+
*/
|
|
4
|
+
export type RunSession = {
|
|
5
|
+
token: number;
|
|
6
|
+
cancelled: boolean;
|
|
7
|
+
cancelSignal: Promise<void>;
|
|
8
|
+
signalCancel: () => void;
|
|
9
|
+
done?: Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export declare const createRunSession: (token: number) => RunSession;
|
|
12
|
+
type CancelOptions<T extends RunSession> = {
|
|
13
|
+
waitForDone?: boolean;
|
|
14
|
+
onCancel?: (session: T) => Promise<void> | void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Canonical run-token lifecycle manager.
|
|
18
|
+
* Centralizes token increment, invalidation, and cancellation semantics.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RunSessionLifecycle<T extends RunSession> {
|
|
21
|
+
private currentToken;
|
|
22
|
+
private active;
|
|
23
|
+
get activeSession(): T | null;
|
|
24
|
+
get activeToken(): number;
|
|
25
|
+
createSession(factory: (token: number) => T): T;
|
|
26
|
+
isTokenActive(token: number): boolean;
|
|
27
|
+
isTokenStale(token: number): boolean;
|
|
28
|
+
invalidateActiveToken(): number;
|
|
29
|
+
clearIfActive(session: T): void;
|
|
30
|
+
cancel(session: T, options?: CancelOptions<T>): Promise<void>;
|
|
31
|
+
cancelActive(options?: CancelOptions<T>): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BrowserProviderContext, BrowserProviderPage } from './providers';
|
|
2
|
+
export type RunnerSessionRecord = {
|
|
3
|
+
id: string;
|
|
4
|
+
testFile: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
runToken: number;
|
|
7
|
+
mode: 'headless-page' | 'headed-iframe';
|
|
8
|
+
createdAt: number;
|
|
9
|
+
context?: BrowserProviderContext;
|
|
10
|
+
page?: BrowserProviderPage;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
type RunnerSessionInput = Omit<RunnerSessionRecord, 'id' | 'createdAt'> & {
|
|
14
|
+
id?: string;
|
|
15
|
+
createdAt?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Execution target index for host scheduling.
|
|
19
|
+
* Provides lookup by session id, test file, and run token without coupling to UI topology.
|
|
20
|
+
*/
|
|
21
|
+
export declare class RunnerSessionRegistry {
|
|
22
|
+
private nextId;
|
|
23
|
+
private sessionsById;
|
|
24
|
+
private sessionIdByTestFile;
|
|
25
|
+
register(input: RunnerSessionInput): RunnerSessionRecord;
|
|
26
|
+
getById(id: string): RunnerSessionRecord | undefined;
|
|
27
|
+
getByTestFile(testFile: string): RunnerSessionRecord | undefined;
|
|
28
|
+
list(): RunnerSessionRecord[];
|
|
29
|
+
listByRunToken(runToken: number): RunnerSessionRecord[];
|
|
30
|
+
deleteById(id: string): boolean;
|
|
31
|
+
deleteByTestFile(testFile: string): boolean;
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DecodedSourceMapXInput, EncodedSourceMapXInput } from '@jridgewell/trace-mapping';
|
|
2
|
+
export type SourceMapPayload = EncodedSourceMapXInput | DecodedSourceMapXInput;
|
|
3
|
+
type Fetcher = typeof fetch;
|
|
4
|
+
export declare const normalizeJavaScriptUrl: (value: string, options?: {
|
|
5
|
+
origin?: string;
|
|
6
|
+
}) => string | null;
|
|
7
|
+
export declare const loadSourceMapWithCache: ({ jsUrl, cache, force, origin, fetcher, }: {
|
|
8
|
+
jsUrl: string;
|
|
9
|
+
cache: Map<string, SourceMapPayload | null>;
|
|
10
|
+
force?: boolean;
|
|
11
|
+
origin?: string;
|
|
12
|
+
fetcher?: Fetcher;
|
|
13
|
+
}) => Promise<SourceMapPayload | null>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TestFileInfo } from './protocol';
|
|
2
|
+
export type WatchPlannerProjectEntry = {
|
|
3
|
+
project: {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
testFiles: string[];
|
|
7
|
+
};
|
|
8
|
+
type WatchRerunPlannerInput = {
|
|
9
|
+
projectEntries: WatchPlannerProjectEntry[];
|
|
10
|
+
previousTestFiles: TestFileInfo[];
|
|
11
|
+
affectedTestFiles: string[];
|
|
12
|
+
};
|
|
13
|
+
export type WatchRerunPlan = {
|
|
14
|
+
currentTestFiles: TestFileInfo[];
|
|
15
|
+
filesChanged: boolean;
|
|
16
|
+
normalizedAffectedTestFiles: string[];
|
|
17
|
+
affectedTestFiles: TestFileInfo[];
|
|
18
|
+
};
|
|
19
|
+
export declare const collectWatchTestFiles: (projectEntries: WatchPlannerProjectEntry[]) => TestFileInfo[];
|
|
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.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Browser mode support for Rstest testing framework.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -20,9 +20,12 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"main": "./dist/index.js",
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
25
|
+
"types": "./dist/browser.d.ts",
|
|
26
|
+
"default": "./dist/browser.js"
|
|
27
|
+
},
|
|
28
|
+
"./internal": {
|
|
26
29
|
"types": "./dist/index.d.ts",
|
|
27
30
|
"default": "./dist/index.js"
|
|
28
31
|
},
|
|
@@ -32,33 +35,35 @@
|
|
|
32
35
|
},
|
|
33
36
|
"files": [
|
|
34
37
|
"dist",
|
|
35
|
-
"src"
|
|
38
|
+
"src",
|
|
39
|
+
"NOTICE",
|
|
40
|
+
"LICENSE-APACHE-2.0"
|
|
36
41
|
],
|
|
37
42
|
"dependencies": {
|
|
38
43
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
39
44
|
"convert-source-map": "^2.0.0",
|
|
40
|
-
"open-editor": "^4.
|
|
45
|
+
"open-editor": "^4.1.1",
|
|
41
46
|
"pathe": "^2.0.3",
|
|
42
47
|
"sirv": "^2.0.4",
|
|
43
|
-
"ws": "^8.
|
|
48
|
+
"ws": "^8.19.0"
|
|
44
49
|
},
|
|
45
50
|
"devDependencies": {
|
|
46
|
-
"@rslib/core": "^0.19.
|
|
51
|
+
"@rslib/core": "^0.19.6",
|
|
47
52
|
"@types/convert-source-map": "^2.0.3",
|
|
48
53
|
"@types/picomatch": "^4.0.2",
|
|
49
54
|
"@types/ws": "^8.18.1",
|
|
50
55
|
"@vitest/snapshot": "^3.2.4",
|
|
51
|
-
"birpc": "
|
|
56
|
+
"birpc": "^4.0.0",
|
|
52
57
|
"picocolors": "^1.1.1",
|
|
53
58
|
"picomatch": "^4.0.3",
|
|
54
|
-
"playwright": "^1.
|
|
59
|
+
"playwright": "^1.58.2",
|
|
55
60
|
"@rstest/browser-ui": "0.0.0",
|
|
56
61
|
"@rstest/tsconfig": "0.0.1",
|
|
57
|
-
"@rstest/core": "0.
|
|
62
|
+
"@rstest/core": "0.9.0"
|
|
58
63
|
},
|
|
59
64
|
"peerDependencies": {
|
|
60
65
|
"playwright": "^1.49.1",
|
|
61
|
-
"@rstest/core": "^0.
|
|
66
|
+
"@rstest/core": "^0.9.0"
|
|
62
67
|
},
|
|
63
68
|
"peerDependenciesMeta": {
|
|
64
69
|
"playwright": {
|
|
@@ -66,7 +71,7 @@
|
|
|
66
71
|
}
|
|
67
72
|
},
|
|
68
73
|
"engines": {
|
|
69
|
-
"node": ">=
|
|
74
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
70
75
|
},
|
|
71
76
|
"publishConfig": {
|
|
72
77
|
"access": "public",
|