@rstest/browser 0.11.5 → 0.11.7
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/browserExecutor.d.ts +7 -5
- package/dist/browserRsbuild.d.ts +139 -0
- 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 +60 -0
- package/dist/dispatchCapabilities.d.ts +1 -2
- package/dist/headedRunRegistry.d.ts +51 -0
- package/dist/headedScheduler.d.ts +58 -0
- package/dist/headlessScheduler.d.ts +38 -0
- package/dist/headlessTransport.d.ts +4 -2
- package/dist/hostController.d.ts +12 -47
- package/dist/hostPayloads.d.ts +24 -0
- package/dist/index.js +2019 -1516
- 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 +42 -0
- package/dist/sourceMap/sourceMapLoader.d.ts +12 -1
- package/dist/watchRerunPlanner.d.ts +20 -4
- package/dist/watchRuntime.d.ts +21 -0
- package/dist/watchSignals.d.ts +29 -0
- package/package.json +12 -12
- 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/506.b2f920fa67.js +0 -194
- package/dist/browser-container/container-static/js/index.d27fd63f5e.js +0 -1
- package/dist/browser.d.ts +0 -2
- package/dist/headlessLatestRerunScheduler.d.ts +0 -18
- package/src/augmentExpect.ts +0 -62
- package/src/browser.ts +0 -3
- package/src/browserExecutor.ts +0 -140
- package/src/browserRpcRegistry.ts +0 -57
- 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/dispatchCapabilities.ts +0 -182
- package/src/dispatchRouter.ts +0 -82
- package/src/env.d.ts +0 -54
- package/src/headedSerialTaskQueue.ts +0 -23
- package/src/headlessLatestRerunScheduler.ts +0 -76
- package/src/headlessTransport.ts +0 -28
- package/src/hostController.ts +0 -4633
- 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/sessionRegistry.ts +0 -89
- package/src/sourceMap/sourceMapLoader.ts +0 -96
- package/src/viewportPresets.ts +0 -69
- package/src/watchRerunPlanner.ts +0 -77
- /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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type BirpcReturn } from 'birpc';
|
|
2
|
+
import { type WebSocket, WebSocketServer } from 'ws';
|
|
3
|
+
import type { BrowserDispatchRequest, BrowserDispatchResponse, BrowserHostConfig, TestFileInfo, VersionedTestFileSet } from './protocol.js';
|
|
4
|
+
/**
|
|
5
|
+
* RPC methods exposed by the host (server) to the container (client).
|
|
6
|
+
* Runner lifecycle events (file-start, case-result, file-complete, log,
|
|
7
|
+
* fatal, ...) do NOT get dedicated methods: the container relays every runner
|
|
8
|
+
* message as a `dispatch` request on the `runner` namespace, stamped with the
|
|
9
|
+
* envelope's run identity, so the host has exactly one inbound gate.
|
|
10
|
+
*/ export type HostRpcMethods = {
|
|
11
|
+
rerunTest: (testFile: string, testNamePattern?: string) => Promise<void>;
|
|
12
|
+
getTestFiles: () => Promise<VersionedTestFileSet>;
|
|
13
|
+
/**
|
|
14
|
+
* The container committed the frame set for this version — every iframe for
|
|
15
|
+
* the set exists in the DOM. Versions are monotonic, so a stale ack can
|
|
16
|
+
* never satisfy a newer wait (a content signature could ABA back to a
|
|
17
|
+
* previously-acked value; a counter cannot).
|
|
18
|
+
*/ onFrameSetReady: (version: number) => Promise<void>;
|
|
19
|
+
dispatch: (request: BrowserDispatchRequest) => Promise<BrowserDispatchResponse>;
|
|
20
|
+
};
|
|
21
|
+
/** RPC methods exposed by the container (client) to the host (server) */ export type ContainerRpcMethods = {
|
|
22
|
+
onTestFileUpdate: (testFiles: TestFileInfo[], version: number) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Grant `runId` (host-minted, already registered host-side) to this file's
|
|
25
|
+
* frame and navigate it. Identity travels IN — the container never mints or
|
|
26
|
+
* echoes identity back.
|
|
27
|
+
*/ reloadTestFile: (testFile: string, runId: string, testNamePattern?: string) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Replace the container's copy of the host config so runner iframes loaded
|
|
30
|
+
* from now on receive fresh values (e.g. the 'u' shortcut flipping
|
|
31
|
+
* `snapshot.updateSnapshot` between watch reruns).
|
|
32
|
+
*/ onHostConfigUpdate: (config: BrowserHostConfig) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
export type ContainerRpc = BirpcReturn<ContainerRpcMethods, HostRpcMethods>;
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// RPC Manager - Encapsulates WebSocket and birpc management
|
|
37
|
+
// ============================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Manages the WebSocket connection and birpc communication with the container UI.
|
|
40
|
+
* Provides a clean interface for sending RPC calls and handling connections.
|
|
41
|
+
*/ export declare class ContainerRpcManager {
|
|
42
|
+
private wss;
|
|
43
|
+
private ws;
|
|
44
|
+
private rpc;
|
|
45
|
+
private methods;
|
|
46
|
+
private onDisconnect?;
|
|
47
|
+
private onAttach?;
|
|
48
|
+
private detachActiveSocketListeners;
|
|
49
|
+
private transportEpoch;
|
|
50
|
+
constructor(wss: WebSocketServer, methods: HostRpcMethods, onDisconnect?: (error: Error) => void, onAttach?: (transportEpoch: number) => void);
|
|
51
|
+
/** Update the RPC methods (used when starting a new test run) */ updateMethods(methods: HostRpcMethods, onDisconnect?: (error: Error) => void, onAttach?: (transportEpoch: number) => void): void;
|
|
52
|
+
private setupConnectionHandler;
|
|
53
|
+
private attachWebSocket;
|
|
54
|
+
/** Check if a container is currently connected */ get isConnected(): boolean;
|
|
55
|
+
/** Get the current WebSocket instance (for reuse in watch mode) */ get currentWebSocket(): WebSocket | null;
|
|
56
|
+
/** Reattach an existing WebSocket (for watch mode reuse) */ reattach(ws: WebSocket): void;
|
|
57
|
+
/** Notify container of test file changes */ notifyTestFileUpdate(files: TestFileInfo[], version: number): Promise<void>;
|
|
58
|
+
/** Push a refreshed host config to the container (watch reruns) */ updateHostConfig(config: BrowserHostConfig): Promise<void>;
|
|
59
|
+
/** Grant a run to a test file's frame and navigate it */ reloadTestFile(testFile: string, runId: string, testNamePattern?: string): Promise<void>;
|
|
60
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Reporter } from '@rstest/core/internal/browser';
|
|
2
1
|
import { HostDispatchRouter } from './dispatchRouter.js';
|
|
2
|
+
import type { ReporterHookArg } from './hostPayloads.js';
|
|
3
3
|
import type { BrowserClientMessage, BrowserDispatchHandler, SnapshotRpcRequest } from './protocol.js';
|
|
4
4
|
export type HostDispatchRouterOptions = ConstructorParameters<typeof HostDispatchRouter>[0];
|
|
5
5
|
type RunnerPayload<TType extends BrowserClientMessage['type']> = Extract<BrowserClientMessage, {
|
|
@@ -7,7 +7,6 @@ type RunnerPayload<TType extends BrowserClientMessage['type']> = Extract<Browser
|
|
|
7
7
|
}> extends {
|
|
8
8
|
payload: infer TPayload;
|
|
9
9
|
} ? TPayload : never;
|
|
10
|
-
type ReporterHookArg<THook extends keyof Reporter> = NonNullable<Reporter[THook]> extends (...args: infer TArgs) => unknown ? TArgs[0] : never;
|
|
11
10
|
type RunnerDispatchFileReadyPayload = ReporterHookArg<'onTestFileReady'>;
|
|
12
11
|
type RunnerDispatchSuiteStartPayload = ReporterHookArg<'onTestSuiteStart'>;
|
|
13
12
|
type RunnerDispatchSuiteResultPayload = ReporterHookArg<'onTestSuiteResult'>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type HeadedRunRegistry = ReturnType<typeof createHeadedRunRegistry>;
|
|
2
|
+
export declare const createHeadedRunRegistry: () => {
|
|
3
|
+
/**
|
|
4
|
+
* Allocate a run and own its deferred, synchronously — the caller sends
|
|
5
|
+
* the reload RPC only after this returns, so no file-set commit or
|
|
6
|
+
* inbound message can land between "the run exists" and "the table knows
|
|
7
|
+
* it" (the ack-window class of race cannot be constructed).
|
|
8
|
+
*/ mint(testPath: string): {
|
|
9
|
+
runId: string;
|
|
10
|
+
settled: Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The one liveness question, asked once per inbound message: may this
|
|
14
|
+
* identity be processed? Any answer of `true` also proves the run's
|
|
15
|
+
* document booted, which disarms the boot deadline.
|
|
16
|
+
*
|
|
17
|
+
* `terminal` marks a message that ends the run ("file-complete" /
|
|
18
|
+
* "fatal"). It claims settlement for the caller's handler and must be
|
|
19
|
+
* asked synchronously, before the handler's first await, so a file-set
|
|
20
|
+
* commit racing the handler cannot settle the run a second time. A second
|
|
21
|
+
* terminal for the same run is answered `false` — it is a duplicate.
|
|
22
|
+
*/ admit(runId: string, terminal: boolean): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A run whose fixture cleanup never finishes will never send its
|
|
25
|
+
* terminal message — a way to go silent that no other deadline covers,
|
|
26
|
+
* so it is a settlement obligation and lives here: the deadline dies
|
|
27
|
+
* with the record in the one guarded delete, which is what makes "run
|
|
28
|
+
* settled elsewhere, timer fires anyway" unrepresentable. Expiry fires
|
|
29
|
+
* only while the run is still open and CLAIMS it in the same synchronous
|
|
30
|
+
* step, exactly like a terminal message's admit: `onExpire`'s handler
|
|
31
|
+
* now owns the settlement, and the recovery it performs (tearing down
|
|
32
|
+
* the container transport) can no longer sweep this run out from under
|
|
33
|
+
* itself. Re-arming replaces the previous deadline.
|
|
34
|
+
*/ armCleanupDeadline(runId: string, ms: number, onExpire: () => void): void;
|
|
35
|
+
disarmCleanupDeadline(runId: string): void;
|
|
36
|
+
resolve(runId: string): void;
|
|
37
|
+
reject(runId: string, error: unknown): void;
|
|
38
|
+
/**
|
|
39
|
+
* The file-set commit's settlement obligation: close every open run whose
|
|
40
|
+
* path left the committed set — the container is about to unmount those
|
|
41
|
+
* frames, so their completions can never arrive (and if one is already in
|
|
42
|
+
* transport, its runId is gone from the table and drops by rule).
|
|
43
|
+
*/ retainPaths(paths: readonly string[]): void;
|
|
44
|
+
/** Transport death: no completion can arrive for any open run. */ rejectAll(error: Error): void;
|
|
45
|
+
/**
|
|
46
|
+
* A new transport attachment orphans every run leased under the previous
|
|
47
|
+
* one, even when the old socket never fired `close` (its listeners are
|
|
48
|
+
* detached before the event can). Runs minted from now on carry the new
|
|
49
|
+
* epoch.
|
|
50
|
+
*/ setTransportEpoch(epoch: number): void;
|
|
51
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { RstestContext, TestFileResult } from '@rstest/core/internal/browser';
|
|
2
|
+
import { type BrowserRuntime } from './browserRsbuild.js';
|
|
3
|
+
import type { HostDispatchRouter } from './dispatchRouter.js';
|
|
4
|
+
import type { BrowserHostConfig, TestFileInfo } from './protocol.js';
|
|
5
|
+
import { planWatchRerun } from './watchRerunPlanner.js';
|
|
6
|
+
import type { BrowserV8CoverageRuntime, BrowserWatchSession, DispatchPageResolver, SchedulerRunResult } from './schedulerSeam.js';
|
|
7
|
+
import type { WatchSignals } from './watchSignals.js';
|
|
8
|
+
type HeadedSchedulerContext = Pick<RstestContext, 'rootPath' | 'snapshotManager' | 'updateReporterResultState'> & {
|
|
9
|
+
normalizedConfig: Pick<RstestContext['normalizedConfig'], 'name'>;
|
|
10
|
+
};
|
|
11
|
+
type HeadedSchedulerDeps = {
|
|
12
|
+
context: HeadedSchedulerContext;
|
|
13
|
+
runtime: BrowserRuntime;
|
|
14
|
+
allTestFiles: TestFileInfo[];
|
|
15
|
+
hostOptions: BrowserHostConfig;
|
|
16
|
+
v8Coverage?: BrowserV8CoverageRuntime;
|
|
17
|
+
projectRoots: Map<string, string>;
|
|
18
|
+
isWatchMode: boolean;
|
|
19
|
+
createDispatchRouter: () => HostDispatchRouter;
|
|
20
|
+
handlers: {
|
|
21
|
+
// For the one result the host authors itself (the cleanup-timeout
|
|
22
|
+
// failure); every runner-authored result flows through the dispatch
|
|
23
|
+
// router instead.
|
|
24
|
+
handleTestFileComplete: (payload: TestFileResult) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
fatalErrorRef: {
|
|
27
|
+
current: Error | null;
|
|
28
|
+
};
|
|
29
|
+
watchSignals: Pick<WatchSignals, 'setDispatchRerun' | 'signalInvalidation'>;
|
|
30
|
+
setDispatchPageResolver: (resolver: DispatchPageResolver) => void;
|
|
31
|
+
createWatchSession: (execute: (testPaths: string[]) => Promise<unknown[]>) => BrowserWatchSession;
|
|
32
|
+
collectProjectEntries: () => Promise<Parameters<typeof planWatchRerun>[0]['projectEntries']>;
|
|
33
|
+
logWatchReady: () => void;
|
|
34
|
+
destroyRuntime: () => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A headed cycle's work list: the files of its scope that still exist, each
|
|
38
|
+
* paired with the test-name pattern whichever trigger put it in scope asked for.
|
|
39
|
+
*
|
|
40
|
+
* Both halves are resolved in one pass, synchronously, at the top of the cycle.
|
|
41
|
+
* A queued scope can go stale before its cycle is dequeued — a later trigger may
|
|
42
|
+
* have rebuilt the file set without one of these files — and it is skipped the
|
|
43
|
+
* way the headless twin skips it; throwing would abandon the still-valid files
|
|
44
|
+
* beside it and fail the run. The patterns are claimed here, and only for the
|
|
45
|
+
* paths in this scope, so a click landing once the cycle is under way keeps its
|
|
46
|
+
* pattern for the cycle it signalled instead of losing it to this one mid-loop.
|
|
47
|
+
*
|
|
48
|
+
* A skipped path keeps its pattern too, for the same reason: consuming it on the
|
|
49
|
+
* way past would leave the next cycle that does run the file — the file set can
|
|
50
|
+
* be rebuilt back — running it unfiltered, so the user's click would silently
|
|
51
|
+
* become a full-file rerun. The cost is one map entry per path that never comes
|
|
52
|
+
* back, which the next launch drops with the map.
|
|
53
|
+
*/ export declare const claimHeadedCycleScope: (testPaths: string[], currentTestFiles: TestFileInfo[], pendingTestNamePatterns: Map<string, string>) => {
|
|
54
|
+
file: TestFileInfo;
|
|
55
|
+
testNamePattern?: string;
|
|
56
|
+
}[];
|
|
57
|
+
export declare const createHeadedScheduler: ({ context, runtime, allTestFiles, hostOptions, v8Coverage, projectRoots, isWatchMode, createDispatchRouter, handlers: { handleTestFileComplete }, fatalErrorRef, watchSignals, setDispatchPageResolver, createWatchSession, collectProjectEntries, logWatchReady, destroyRuntime }: HeadedSchedulerDeps) => Promise<SchedulerRunResult>;
|
|
58
|
+
export { };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RstestContext, TestFileResult } from '@rstest/core/internal/browser';
|
|
2
|
+
import { type BrowserRuntime } from './browserRsbuild.js';
|
|
3
|
+
import type { HostDispatchRouterOptions } from './dispatchCapabilities.js';
|
|
4
|
+
import type { HostDispatchRouter } from './dispatchRouter.js';
|
|
5
|
+
import { type FatalPayload } from './hostPayloads.js';
|
|
6
|
+
import type { BrowserHostConfig, BrowserProjectRuntime, TestFileInfo } from './protocol.js';
|
|
7
|
+
import type { BrowserProviderBrowser } from './providers/index.js';
|
|
8
|
+
import { planWatchRerun } from './watchRerunPlanner.js';
|
|
9
|
+
import type { BrowserV8CoverageRuntime, BrowserWatchSession, DispatchPageResolver, SchedulerRunResult } from './schedulerSeam.js';
|
|
10
|
+
import type { WatchSignals } from './watchSignals.js';
|
|
11
|
+
type HeadlessSchedulerContext = Pick<RstestContext, 'command' | 'rootPath' | 'snapshotManager' | 'stateManager' | 'updateReporterResultState'> & {
|
|
12
|
+
normalizedConfig: Pick<RstestContext['normalizedConfig'], 'bail' | 'pool'>;
|
|
13
|
+
};
|
|
14
|
+
type HeadlessSchedulerDeps = {
|
|
15
|
+
context: HeadlessSchedulerContext;
|
|
16
|
+
browser: BrowserProviderBrowser;
|
|
17
|
+
browserLaunchOptions: BrowserRuntime['browserLaunchOptions'];
|
|
18
|
+
projectServers: BrowserRuntime['projectServers'];
|
|
19
|
+
v8Coverage?: BrowserV8CoverageRuntime;
|
|
20
|
+
allTestFiles: TestFileInfo[];
|
|
21
|
+
projectRuntimeConfigs: BrowserProjectRuntime[];
|
|
22
|
+
hostOptions: BrowserHostConfig;
|
|
23
|
+
watchState: BrowserRuntime['watchState'];
|
|
24
|
+
isWatchMode: boolean;
|
|
25
|
+
createDispatchRouter: (options?: HostDispatchRouterOptions) => HostDispatchRouter;
|
|
26
|
+
handlers: {
|
|
27
|
+
handleFatal: (payload: FatalPayload) => Promise<void>;
|
|
28
|
+
handleTestFileComplete: (payload: TestFileResult) => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
watchSignals: Pick<WatchSignals, 'setDispatchRerun' | 'setInterrupt' | 'signalInvalidation'>;
|
|
31
|
+
setDispatchPageResolver: (resolver: DispatchPageResolver) => void;
|
|
32
|
+
createWatchSession: (execute: (testPaths: string[]) => Promise<unknown[]>) => BrowserWatchSession;
|
|
33
|
+
collectProjectEntries: () => Promise<Parameters<typeof planWatchRerun>[0]['projectEntries']>;
|
|
34
|
+
logWatchReady: () => void;
|
|
35
|
+
destroyRuntime: () => Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
export declare const createHeadlessScheduler: ({ context, browser, browserLaunchOptions, projectServers, v8Coverage, allTestFiles, projectRuntimeConfigs, hostOptions, watchState, isWatchMode, createDispatchRouter, handlers: { handleFatal, handleTestFileComplete }, watchSignals, setDispatchPageResolver, createWatchSession, collectProjectEntries, logWatchReady, destroyRuntime }: HeadlessSchedulerDeps) => Promise<SchedulerRunResult>;
|
|
38
|
+
export { };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BrowserDispatchRequest, BrowserDispatchResponse, RunnerEnvelope } from './protocol.js';
|
|
2
2
|
import type { BrowserProviderPage } from './providers/index.js';
|
|
3
3
|
type HeadlessRunnerTransportHandlers = {
|
|
4
|
-
|
|
4
|
+
// The envelope's `runId` is ignored here: headless identity is the
|
|
5
|
+
// host-injected `runToken` bound at this transport attachment.
|
|
6
|
+
onDispatchMessage: (envelope: RunnerEnvelope) => Promise<void>;
|
|
5
7
|
onDispatchRpc: (request: BrowserDispatchRequest) => Promise<BrowserDispatchResponse>;
|
|
6
8
|
};
|
|
7
9
|
/**
|
package/dist/hostController.d.ts
CHANGED
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
import { type BrowserTestRunOptions, type BrowserTestRunResult, type ListBrowserTestsOptions, type ListCommandResult, type RstestContext } from '@rstest/core/internal/browser';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { type BrowserTestRunOptions, type BrowserTestRunResult, type ExecutorInvalidationCallback, type ListBrowserTestsOptions, type ListCommandResult, type RstestContext } from '@rstest/core/internal/browser';
|
|
2
|
+
import type { BrowserWatchSession } from './schedulerSeam.js';
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export type BrowserControllerOptions = BrowserTestRunOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* Watch only: core's watch-cycle driver (see `TestExecutor.onInvalidate`).
|
|
7
|
+
* Its promise settles when the cycle it queued has finalized, which only an
|
|
8
|
+
* explicit request may wait for (see `signalInvalidation`).
|
|
9
|
+
*/ onInvalidate?: ExecutorInvalidationCallback;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* Rsbuild's `devServer.listen()` may return `0` when configured with
|
|
14
|
-
* `server.port: 0` because its internal `getPort` never reads back the
|
|
15
|
-
* OS-assigned ephemeral port. This helper falls back to
|
|
16
|
-
* `httpServer.address()` to obtain the real bound port.
|
|
17
|
-
*/ export declare const resolveListenPort: (listenPort: number, httpServer: {
|
|
18
|
-
address: () => ReturnType<import('node:net').Server['address']>;
|
|
19
|
-
} | null) => number;
|
|
20
|
-
export declare const createBrowserLazyCompilationConfig: (setupFiles: string[]) => BrowserLazyCompilationConfig;
|
|
21
|
-
/**
|
|
22
|
-
* HMR — and the lazyCompilation transport it carries — is wired only for headed
|
|
23
|
-
* watch, the sole path that reuses a persistent page and applies module updates
|
|
24
|
-
* in place. Headless always loads each test file in a fresh page (pulling the
|
|
25
|
-
* latest incrementally-built chunks over HTTP), and one-shot runs never rerun,
|
|
26
|
-
* so pushing HMR updates there is dead weight that only races factory
|
|
27
|
-
* registration for chunk-split node_modules (rspack#11922) and lets
|
|
28
|
-
* lazyCompilation's accept-chain walk abort the next spec when no boundary
|
|
29
|
-
* exists (#1472). Disabling HMR does not make watch rebuilds any less
|
|
30
|
-
* incremental — HMR is only the client push transport.
|
|
31
|
-
*/ export declare const shouldEnableBrowserHmr: (isWatchMode: boolean, isHeadless: boolean) => boolean;
|
|
32
|
-
export declare const createBrowserRsbuildDevConfig: (enableHmr: boolean) => {
|
|
33
|
-
writeToDisk: boolean;
|
|
34
|
-
hmr: boolean;
|
|
35
|
-
client: {
|
|
36
|
-
logLevel: 'error';
|
|
37
|
-
};
|
|
11
|
+
export type BrowserControllerResult = BrowserTestRunResult & {
|
|
12
|
+
watchSession?: BrowserWatchSession;
|
|
38
13
|
};
|
|
39
|
-
export declare const
|
|
40
|
-
// Host-side mirror of the browser runtime's `toContextKey` (client/entry.ts):
|
|
41
|
-
// `./<path-relative-to-project-root>` with forward slashes. The runtime derives
|
|
42
|
-
// the same key from the target test file, so the non-watch import map below must
|
|
43
|
-
// key by the identical form for `loadTest(key)` to resolve.
|
|
44
|
-
export declare const toContextKey: (filePath: string, projectRootPosix: string) => string;
|
|
45
|
-
// ============================================================================
|
|
46
|
-
// Main Entry Point
|
|
47
|
-
// ============================================================================
|
|
48
|
-
export declare const runBrowserController: (context: RstestContext, options?: BrowserTestRunOptions) => Promise<BrowserTestRunResult | void>;
|
|
14
|
+
export declare const runBrowserController: (context: RstestContext, options?: BrowserControllerOptions) => Promise<BrowserControllerResult | void>;
|
|
49
15
|
// ============================================================================
|
|
50
16
|
// List Browser Tests
|
|
51
17
|
// ============================================================================
|
|
@@ -62,4 +28,3 @@ export declare const runBrowserController: (context: RstestContext, options?: Br
|
|
|
62
28
|
* This function creates a headless browser runtime, loads test files,
|
|
63
29
|
* and collects their test structure (describe/test declarations).
|
|
64
30
|
*/ export declare const listBrowserTests: (context: RstestContext, options?: ListBrowserTestsOptions) => Promise<ListBrowserTestsResult>;
|
|
65
|
-
export { };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Reporter } from '@rstest/core/internal/browser';
|
|
2
|
+
import type { BrowserLogPayload } from './protocol.js';
|
|
3
|
+
/** Payload for test file start event */ export type TestFileStartPayload = {
|
|
4
|
+
testPath: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
};
|
|
7
|
+
/** Payload for log event — single-sourced from the wire protocol. */ export type LogPayload = BrowserLogPayload;
|
|
8
|
+
/** Payload for fatal error event */ export type FatalPayload = {
|
|
9
|
+
message: string;
|
|
10
|
+
stack?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ReporterHookArg<THook extends keyof Reporter> = NonNullable<Reporter[THook]> extends (...args: infer TArgs) => unknown ? TArgs[0] : never;
|
|
13
|
+
export type TestFileReadyPayload = ReporterHookArg<'onTestFileReady'>;
|
|
14
|
+
export type TestSuiteStartPayload = ReporterHookArg<'onTestSuiteStart'>;
|
|
15
|
+
export type TestSuiteResultPayload = ReporterHookArg<'onTestSuiteResult'>;
|
|
16
|
+
export type TestCaseStartPayload = ReporterHookArg<'onTestCaseStart'>;
|
|
17
|
+
export type DeferredPromise<T> = {
|
|
18
|
+
promise: Promise<T>;
|
|
19
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
20
|
+
reject: (reason?: unknown) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const getFileTaskId: (testPath: string) => string;
|
|
23
|
+
export declare const toError: (error: unknown) => Error;
|
|
24
|
+
export declare const createDeferredPromise: <T>() => DeferredPromise<T>;
|