@rstest/browser 0.11.6 → 0.11.8
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/browser-container/container-static/css/index.43daaf6c93.css +1 -0
- package/dist/browser-container/container-static/js/260.3739fe815c.js +194 -0
- package/dist/browser-container/container-static/js/index.c0f87bfb3e.js +1 -0
- package/dist/browser-container/index.html +1 -1
- package/dist/browserRsbuild.d.ts +24 -4
- package/dist/browserV8Coverage.d.ts +15 -0
- package/dist/client/240~1.js +150 -0
- package/dist/{augmentExpect.d.ts → client/client/augmentExpect.d.ts} +1 -1
- package/dist/client/{browserRpc.d.ts → client/browserRpc.d.ts} +1 -1
- package/dist/client/{dispatchTransport.d.ts → client/dispatchTransport.d.ts} +8 -4
- package/dist/client/client/index.d.ts +2 -0
- package/dist/client/client/runIdentity.d.ts +12 -0
- package/dist/client/client/runner.d.ts +4 -0
- package/dist/client/client/snapshot.d.ts +27 -0
- package/dist/client/client/sourceMapSupport.d.ts +36 -0
- package/dist/{browser.js → client/index.js} +3 -102
- package/dist/client/protocol.d.ts +225 -0
- package/dist/client/rpcProtocol.d.ts +138 -0
- package/dist/client/runner.js +675 -0
- package/dist/client/sourceMap/sourceMapLoader.d.ts +25 -0
- package/dist/containerRpc.d.ts +27 -19
- package/dist/headedRunRegistry.d.ts +51 -0
- package/dist/headedScheduler.d.ts +10 -10
- package/dist/headlessScheduler.d.ts +5 -4
- package/dist/headlessTransport.d.ts +4 -2
- package/dist/hostPayloads.d.ts +1 -7
- package/dist/index.js +840 -330
- package/dist/protocol.d.ts +48 -8
- package/dist/providers/index.d.ts +21 -0
- package/dist/providers/playwright/v8Coverage.d.ts +2 -0
- package/dist/rpcProtocol.d.ts +1 -2
- package/dist/schedulerSeam.d.ts +5 -0
- package/dist/sourceMap/sourceMapLoader.d.ts +12 -1
- package/dist/watchRerunPlanner.d.ts +20 -9
- package/dist/watchSignals.d.ts +8 -1
- package/package.json +11 -11
- package/dist/33.js +0 -7
- package/dist/browser-container/container-static/css/index.0521ff95b1.css +0 -1
- package/dist/browser-container/container-static/js/683.4f821ce8f1.js +0 -194
- package/dist/browser-container/container-static/js/index.568aa7cb35.js +0 -1
- package/dist/browser.d.ts +0 -2
- package/src/augmentExpect.ts +0 -62
- package/src/browser.ts +0 -3
- package/src/browserExecutor.ts +0 -222
- package/src/browserRpcRegistry.ts +0 -57
- package/src/browserRsbuild.ts +0 -1927
- package/src/client/api.ts +0 -213
- package/src/client/browserRpc.ts +0 -86
- package/src/client/dispatchTransport.ts +0 -240
- package/src/client/entry.ts +0 -807
- package/src/client/locator.ts +0 -448
- package/src/client/snapshot.ts +0 -113
- package/src/client/sourceMapSupport.ts +0 -159
- package/src/concurrency.ts +0 -65
- package/src/configValidation.ts +0 -263
- package/src/containerRpc.ts +0 -206
- package/src/dispatchCapabilities.ts +0 -177
- package/src/dispatchRouter.ts +0 -82
- package/src/env.d.ts +0 -54
- package/src/headedScheduler.ts +0 -664
- package/src/headedSerialTaskQueue.ts +0 -23
- package/src/headlessScheduler.ts +0 -566
- package/src/headlessTransport.ts +0 -28
- package/src/hostController.ts +0 -1365
- package/src/hostPayloads.ts +0 -62
- package/src/index.ts +0 -51
- package/src/manifest.d.ts +0 -41
- package/src/protocol.ts +0 -225
- package/src/providers/index.ts +0 -126
- package/src/providers/playwright/compileLocator.ts +0 -130
- package/src/providers/playwright/dispatchBrowserRpc.ts +0 -372
- package/src/providers/playwright/expectUtils.ts +0 -57
- package/src/providers/playwright/implementation.ts +0 -35
- package/src/providers/playwright/index.ts +0 -1
- package/src/providers/playwright/runtime.ts +0 -159
- package/src/providers/playwright/textMatcher.ts +0 -10
- package/src/rpcProtocol.ts +0 -218
- package/src/runSession.ts +0 -110
- package/src/schedulerSeam.ts +0 -49
- package/src/sessionRegistry.ts +0 -89
- package/src/sourceMap/sourceMapLoader.ts +0 -96
- package/src/viewportPresets.ts +0 -69
- package/src/watchRerunPlanner.ts +0 -88
- package/src/watchRuntime.ts +0 -83
- package/src/watchSignals.ts +0 -93
- /package/dist/{rslib-runtime.js → 612~0.js} +0 -0
- /package/dist/client/{api.d.ts → client/api.d.ts} +0 -0
- /package/dist/client/{locator.d.ts → client/locator.d.ts} +0 -0
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { HostDispatchRouter } from './dispatchRouter';
|
|
2
|
-
import type { ReporterHookArg } from './hostPayloads';
|
|
3
|
-
import {
|
|
4
|
-
DISPATCH_NAMESPACE_RUNNER,
|
|
5
|
-
DISPATCH_NAMESPACE_SNAPSHOT,
|
|
6
|
-
} from './protocol';
|
|
7
|
-
import type {
|
|
8
|
-
BrowserClientMessage,
|
|
9
|
-
BrowserDispatchHandler,
|
|
10
|
-
BrowserDispatchRequest,
|
|
11
|
-
RunnerDispatchMethod,
|
|
12
|
-
SnapshotRpcMethod,
|
|
13
|
-
SnapshotRpcMethodArgs,
|
|
14
|
-
SnapshotRpcRequest,
|
|
15
|
-
} from './protocol';
|
|
16
|
-
|
|
17
|
-
export type HostDispatchRouterOptions = ConstructorParameters<
|
|
18
|
-
typeof HostDispatchRouter
|
|
19
|
-
>[0];
|
|
20
|
-
|
|
21
|
-
type RunnerPayload<TType extends BrowserClientMessage['type']> =
|
|
22
|
-
Extract<BrowserClientMessage, { type: TType }> extends {
|
|
23
|
-
payload: infer TPayload;
|
|
24
|
-
}
|
|
25
|
-
? TPayload
|
|
26
|
-
: never;
|
|
27
|
-
|
|
28
|
-
type RunnerDispatchFileReadyPayload = ReporterHookArg<'onTestFileReady'>;
|
|
29
|
-
type RunnerDispatchSuiteStartPayload = ReporterHookArg<'onTestSuiteStart'>;
|
|
30
|
-
type RunnerDispatchSuiteResultPayload = ReporterHookArg<'onTestSuiteResult'>;
|
|
31
|
-
type RunnerDispatchCaseStartPayload = ReporterHookArg<'onTestCaseStart'>;
|
|
32
|
-
|
|
33
|
-
type RunnerDispatchCallbacks = {
|
|
34
|
-
onTestFileStart: (payload: RunnerPayload<'file-start'>) => Promise<void>;
|
|
35
|
-
onTestFileReady: (payload: RunnerDispatchFileReadyPayload) => Promise<void>;
|
|
36
|
-
onTestSuiteStart: (payload: RunnerDispatchSuiteStartPayload) => Promise<void>;
|
|
37
|
-
onTestSuiteResult: (
|
|
38
|
-
payload: RunnerDispatchSuiteResultPayload,
|
|
39
|
-
) => Promise<void>;
|
|
40
|
-
onTestCaseStart: (payload: RunnerDispatchCaseStartPayload) => Promise<void>;
|
|
41
|
-
onTestCaseResult: (payload: RunnerPayload<'case-result'>) => Promise<void>;
|
|
42
|
-
onTestFileComplete: (
|
|
43
|
-
payload: RunnerPayload<'file-complete'>,
|
|
44
|
-
) => Promise<void>;
|
|
45
|
-
onLog: (payload: RunnerPayload<'log'>) => Promise<void>;
|
|
46
|
-
onFatal: (payload: RunnerPayload<'fatal'>) => Promise<void>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type CreateHostDispatchRouterOptions = {
|
|
50
|
-
routerOptions?: HostDispatchRouterOptions;
|
|
51
|
-
runnerCallbacks: RunnerDispatchCallbacks;
|
|
52
|
-
runSnapshotRpc: (request: SnapshotRpcRequest) => Promise<unknown>;
|
|
53
|
-
extensionHandlers?: Map<string, BrowserDispatchHandler>;
|
|
54
|
-
onDuplicateNamespace?: (namespace: string) => void;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Builds a typed {@link SnapshotRpcRequest} from the untrusted wire envelope,
|
|
59
|
-
* one builder per method. Keyed by {@link SnapshotRpcMethod}, so adding or
|
|
60
|
-
* renaming a method in the union forces a matching entry here — a stale name
|
|
61
|
-
* becomes a compile error instead of silently falling through to `null`. The
|
|
62
|
-
* `args` casts are the unavoidable trust boundary for inbound wire data.
|
|
63
|
-
*/
|
|
64
|
-
const snapshotRequestBuilders: {
|
|
65
|
-
[M in SnapshotRpcMethod]: (
|
|
66
|
-
id: string,
|
|
67
|
-
args: BrowserDispatchRequest['args'],
|
|
68
|
-
) => Extract<SnapshotRpcRequest, { method: M }>;
|
|
69
|
-
} = {
|
|
70
|
-
resolveSnapshotPath: (id, args) => ({
|
|
71
|
-
id,
|
|
72
|
-
method: 'resolveSnapshotPath',
|
|
73
|
-
args: args as SnapshotRpcMethodArgs['resolveSnapshotPath'],
|
|
74
|
-
}),
|
|
75
|
-
readSnapshotFile: (id, args) => ({
|
|
76
|
-
id,
|
|
77
|
-
method: 'readSnapshotFile',
|
|
78
|
-
args: args as SnapshotRpcMethodArgs['readSnapshotFile'],
|
|
79
|
-
}),
|
|
80
|
-
saveSnapshotFile: (id, args) => ({
|
|
81
|
-
id,
|
|
82
|
-
method: 'saveSnapshotFile',
|
|
83
|
-
args: args as SnapshotRpcMethodArgs['saveSnapshotFile'],
|
|
84
|
-
}),
|
|
85
|
-
removeSnapshotFile: (id, args) => ({
|
|
86
|
-
id,
|
|
87
|
-
method: 'removeSnapshotFile',
|
|
88
|
-
args: args as SnapshotRpcMethodArgs['removeSnapshotFile'],
|
|
89
|
-
}),
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const toSnapshotRpcRequest = (
|
|
93
|
-
request: BrowserDispatchRequest,
|
|
94
|
-
): SnapshotRpcRequest | null => {
|
|
95
|
-
const builder = snapshotRequestBuilders[
|
|
96
|
-
request.method as SnapshotRpcMethod
|
|
97
|
-
] as
|
|
98
|
-
| ((id: string, args: BrowserDispatchRequest['args']) => SnapshotRpcRequest)
|
|
99
|
-
| undefined;
|
|
100
|
-
return builder ? builder(request.requestId, request.args) : null;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const createHostDispatchRouter = ({
|
|
104
|
-
routerOptions,
|
|
105
|
-
runnerCallbacks,
|
|
106
|
-
runSnapshotRpc,
|
|
107
|
-
extensionHandlers,
|
|
108
|
-
onDuplicateNamespace,
|
|
109
|
-
}: CreateHostDispatchRouterOptions): HostDispatchRouter => {
|
|
110
|
-
const router = new HostDispatchRouter(routerOptions);
|
|
111
|
-
|
|
112
|
-
// Keyed by RunnerDispatchMethod so adding a runner method to that union forces
|
|
113
|
-
// a handler entry here (a missing key is a compile error) — the previous
|
|
114
|
-
// `switch` with `default: break` silently dropped unhandled methods. The
|
|
115
|
-
// `args` casts are checked against each callback's parameter type, so a wrong
|
|
116
|
-
// payload type also fails to compile.
|
|
117
|
-
const runnerMethodHandlers: {
|
|
118
|
-
[M in RunnerDispatchMethod]: (
|
|
119
|
-
args: BrowserDispatchRequest['args'],
|
|
120
|
-
) => Promise<void>;
|
|
121
|
-
} = {
|
|
122
|
-
'file-start': (args) =>
|
|
123
|
-
runnerCallbacks.onTestFileStart(args as RunnerPayload<'file-start'>),
|
|
124
|
-
'file-ready': (args) =>
|
|
125
|
-
runnerCallbacks.onTestFileReady(args as RunnerDispatchFileReadyPayload),
|
|
126
|
-
'suite-start': (args) =>
|
|
127
|
-
runnerCallbacks.onTestSuiteStart(args as RunnerDispatchSuiteStartPayload),
|
|
128
|
-
'suite-result': (args) =>
|
|
129
|
-
runnerCallbacks.onTestSuiteResult(
|
|
130
|
-
args as RunnerDispatchSuiteResultPayload,
|
|
131
|
-
),
|
|
132
|
-
'case-start': (args) =>
|
|
133
|
-
runnerCallbacks.onTestCaseStart(args as RunnerDispatchCaseStartPayload),
|
|
134
|
-
'case-result': (args) =>
|
|
135
|
-
runnerCallbacks.onTestCaseResult(args as RunnerPayload<'case-result'>),
|
|
136
|
-
'file-complete': (args) =>
|
|
137
|
-
runnerCallbacks.onTestFileComplete(
|
|
138
|
-
args as RunnerPayload<'file-complete'>,
|
|
139
|
-
),
|
|
140
|
-
log: (args) => runnerCallbacks.onLog(args as RunnerPayload<'log'>),
|
|
141
|
-
fatal: (args) => runnerCallbacks.onFatal(args as RunnerPayload<'fatal'>),
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
router.register(
|
|
145
|
-
DISPATCH_NAMESPACE_RUNNER,
|
|
146
|
-
async (request: BrowserDispatchRequest) => {
|
|
147
|
-
// `request.method` is untrusted wire data, so the lookup may miss. Unknown
|
|
148
|
-
// methods are ignored for forward-compatibility with newer runners,
|
|
149
|
-
// matching the previous `default: break`.
|
|
150
|
-
await runnerMethodHandlers[request.method as RunnerDispatchMethod]?.(
|
|
151
|
-
request.args,
|
|
152
|
-
);
|
|
153
|
-
},
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
router.register(
|
|
157
|
-
DISPATCH_NAMESPACE_SNAPSHOT,
|
|
158
|
-
async (request: BrowserDispatchRequest) => {
|
|
159
|
-
const snapshotRequest = toSnapshotRpcRequest(request);
|
|
160
|
-
if (!snapshotRequest) {
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
return runSnapshotRpc(snapshotRequest);
|
|
164
|
-
},
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
for (const [namespace, handler] of extensionHandlers ?? []) {
|
|
168
|
-
if (router.has(namespace)) {
|
|
169
|
-
onDuplicateNamespace?.(namespace);
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
router.register(namespace, handler);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return router;
|
|
177
|
-
};
|
package/src/dispatchRouter.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BrowserDispatchRequest,
|
|
3
|
-
BrowserDispatchResponse,
|
|
4
|
-
} from './protocol';
|
|
5
|
-
|
|
6
|
-
type DispatchHandler = (request: BrowserDispatchRequest) => Promise<unknown>;
|
|
7
|
-
|
|
8
|
-
type HostDispatchRouterOptions = {
|
|
9
|
-
isRunTokenStale?: (runToken: number) => boolean;
|
|
10
|
-
onStale?: (request: BrowserDispatchRequest) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const toErrorMessage = (error: unknown): string => {
|
|
14
|
-
return error instanceof Error ? error.message : String(error);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Host-side routing layer for dispatch envelopes.
|
|
19
|
-
* Capabilities are registered by namespace, while routing stays transport-agnostic.
|
|
20
|
-
*/
|
|
21
|
-
export class HostDispatchRouter {
|
|
22
|
-
private handlers = new Map<string, DispatchHandler>();
|
|
23
|
-
private options: HostDispatchRouterOptions;
|
|
24
|
-
|
|
25
|
-
constructor(options?: HostDispatchRouterOptions) {
|
|
26
|
-
this.options = options ?? {};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
register(namespace: string, handler: DispatchHandler): void {
|
|
30
|
-
this.handlers.set(namespace, handler);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
unregister(namespace: string): void {
|
|
34
|
-
this.handlers.delete(namespace);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
has(namespace: string): boolean {
|
|
38
|
-
return this.handlers.has(namespace);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async dispatch(
|
|
42
|
-
request: BrowserDispatchRequest,
|
|
43
|
-
): Promise<BrowserDispatchResponse> {
|
|
44
|
-
const runToken = request.runToken;
|
|
45
|
-
if (
|
|
46
|
-
typeof runToken === 'number' &&
|
|
47
|
-
this.options.isRunTokenStale?.(runToken)
|
|
48
|
-
) {
|
|
49
|
-
// Return a stale marker so callers can drop old-run writes safely.
|
|
50
|
-
this.options.onStale?.(request);
|
|
51
|
-
return {
|
|
52
|
-
requestId: request.requestId,
|
|
53
|
-
runToken,
|
|
54
|
-
stale: true,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const handler = this.handlers.get(request.namespace);
|
|
59
|
-
if (!handler) {
|
|
60
|
-
return {
|
|
61
|
-
requestId: request.requestId,
|
|
62
|
-
runToken,
|
|
63
|
-
error: `No dispatch handler registered for namespace "${request.namespace}"`,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
const result = await handler(request);
|
|
69
|
-
return {
|
|
70
|
-
requestId: request.requestId,
|
|
71
|
-
runToken,
|
|
72
|
-
result,
|
|
73
|
-
};
|
|
74
|
-
} catch (error) {
|
|
75
|
-
return {
|
|
76
|
-
requestId: request.requestId,
|
|
77
|
-
runToken,
|
|
78
|
-
error: toErrorMessage(error),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
package/src/env.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { DISPATCH_MESSAGE_TYPE, DISPATCH_RPC_BRIDGE_NAME } from './protocol';
|
|
2
|
-
import type {
|
|
3
|
-
BrowserClientMessage,
|
|
4
|
-
BrowserDispatchRequest,
|
|
5
|
-
BrowserHostConfig,
|
|
6
|
-
} from './protocol';
|
|
7
|
-
|
|
8
|
-
declare module '@rstest/browser-manifest' {
|
|
9
|
-
export type ManifestProjectConfig = {
|
|
10
|
-
name: string;
|
|
11
|
-
environmentName: string;
|
|
12
|
-
projectRoot: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type ManifestTestContext = {
|
|
16
|
-
getTestKeys: () => string[];
|
|
17
|
-
loadTest: (key: string) => Promise<unknown>;
|
|
18
|
-
projectRoot: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const projects: ManifestProjectConfig[];
|
|
22
|
-
|
|
23
|
-
export const projectSetupLoaders: Record<
|
|
24
|
-
string,
|
|
25
|
-
Array<() => Promise<unknown>>
|
|
26
|
-
>;
|
|
27
|
-
|
|
28
|
-
export const projectTestContexts: Record<string, ManifestTestContext>;
|
|
29
|
-
|
|
30
|
-
// Backward compatibility exports
|
|
31
|
-
export const projectConfig: ManifestProjectConfig | undefined;
|
|
32
|
-
export const setupLoaders: Array<() => Promise<unknown>>;
|
|
33
|
-
export const getTestKeys: () => string[];
|
|
34
|
-
export const loadTest: (key: string) => Promise<unknown>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
declare global {
|
|
38
|
-
const RSTEST_VERSION: string;
|
|
39
|
-
|
|
40
|
-
interface Window {
|
|
41
|
-
__RSTEST_BROWSER_OPTIONS__?: BrowserHostConfig;
|
|
42
|
-
// Keyed by the sentinel constants so the declared global name and the
|
|
43
|
-
// constant are the same source — renaming a constant moves this key with it,
|
|
44
|
-
// and every `window[CONST]` access site stays in lockstep automatically.
|
|
45
|
-
[DISPATCH_MESSAGE_TYPE]?: (message: BrowserClientMessage) => void;
|
|
46
|
-
[DISPATCH_RPC_BRIDGE_NAME]?: (
|
|
47
|
-
request: BrowserDispatchRequest,
|
|
48
|
-
) => Promise<unknown>;
|
|
49
|
-
__rstest_container_dispatch__?: (data: unknown) => void;
|
|
50
|
-
__rstest_container_on__?: (data: unknown) => void;
|
|
51
|
-
__RSTEST_DONE__?: boolean;
|
|
52
|
-
__RSTEST_TEST_FILES__?: string[];
|
|
53
|
-
}
|
|
54
|
-
}
|