@rstest/browser 0.11.4 → 0.11.6

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 (40) hide show
  1. package/dist/browser-container/container-static/js/683.4f821ce8f1.js +194 -0
  2. package/dist/browser-container/container-static/js/index.568aa7cb35.js +1 -0
  3. package/dist/browser-container/container-static/js/lib-react.e24a1d366b.js +2 -0
  4. package/dist/browser-container/index.html +1 -1
  5. package/dist/browserExecutor.d.ts +7 -5
  6. package/dist/browserRsbuild.d.ts +119 -0
  7. package/dist/containerRpc.d.ts +52 -0
  8. package/dist/dispatchCapabilities.d.ts +1 -2
  9. package/dist/headedScheduler.d.ts +58 -0
  10. package/dist/headlessScheduler.d.ts +37 -0
  11. package/dist/hostController.d.ts +12 -47
  12. package/dist/hostPayloads.d.ts +30 -0
  13. package/dist/index.js +1738 -1793
  14. package/dist/protocol.d.ts +5 -0
  15. package/dist/schedulerSeam.d.ts +37 -0
  16. package/dist/watchRerunPlanner.d.ts +5 -0
  17. package/dist/watchRuntime.d.ts +21 -0
  18. package/dist/watchSignals.d.ts +22 -0
  19. package/package.json +5 -5
  20. package/src/browserExecutor.ts +90 -8
  21. package/src/browserRsbuild.ts +1927 -0
  22. package/src/client/entry.ts +3 -0
  23. package/src/containerRpc.ts +206 -0
  24. package/src/dispatchCapabilities.ts +1 -6
  25. package/src/headedScheduler.ts +664 -0
  26. package/src/headlessScheduler.ts +566 -0
  27. package/src/hostController.ts +855 -4163
  28. package/src/hostPayloads.ts +62 -0
  29. package/src/protocol.ts +6 -0
  30. package/src/schedulerSeam.ts +49 -0
  31. package/src/watchRerunPlanner.ts +18 -7
  32. package/src/watchRuntime.ts +83 -0
  33. package/src/watchSignals.ts +93 -0
  34. package/dist/browser-container/container-static/js/243.a8eed2b9e7.js +0 -27406
  35. package/dist/browser-container/container-static/js/243.a8eed2b9e7.js.LICENSE.txt +0 -1
  36. package/dist/browser-container/container-static/js/index.84aaafaf21.js +0 -3058
  37. package/dist/browser-container/container-static/js/lib-react.62b27a21db.js +0 -8454
  38. package/dist/browser-container/container-static/js/lib-react.62b27a21db.js.LICENSE.txt +0 -1
  39. package/dist/headlessLatestRerunScheduler.d.ts +0 -18
  40. package/src/headlessLatestRerunScheduler.ts +0 -76
@@ -0,0 +1,119 @@
1
+ import { type ProjectContext, type RstestContext, rsbuild, type WatchInvalidationState } from '@rstest/core/internal/browser';
2
+ import { WebSocketServer } from 'ws';
3
+ import type { ContainerRpcManager } from './containerRpc.js';
4
+ import type { BrowserDispatchHandler, BrowserHostConfig, BrowserProjectRuntime, TestFileInfo } from './protocol.js';
5
+ import type { BrowserProvider, BrowserProviderBrowser, BrowserProviderContext, BrowserProviderPage } from './providers/index.js';
6
+ type RsbuildDevServer = rsbuild.RsbuildDevServer;
7
+ type RsbuildInstance = rsbuild.RsbuildInstance;
8
+ export declare const serializeForInlineScript: (value: unknown) => string;
9
+ // ============================================================================
10
+ // Type Definitions
11
+ type BrowserProjectEntries = {
12
+ project: ProjectContext;
13
+ setupFiles: string[];
14
+ testFiles: string[];
15
+ };
16
+ export type BrowserProviderProject = {
17
+ rootPath: string;
18
+ provider: BrowserProvider;
19
+ };
20
+ type BrowserLaunchOptions = {
21
+ provider: BrowserProvider;
22
+ browser: ProjectContext['normalizedConfig']['browser']['browser'];
23
+ headless: ProjectContext['normalizedConfig']['browser']['headless'];
24
+ port: ProjectContext['normalizedConfig']['browser']['port'];
25
+ strictPort: ProjectContext['normalizedConfig']['browser']['strictPort'];
26
+ providerOptions: Record<string, unknown>;
27
+ };
28
+ export type BrowserProjectServer = {
29
+ projectName: string;
30
+ environmentName: string;
31
+ rsbuildInstance: RsbuildInstance;
32
+ devServer: RsbuildDevServer;
33
+ port: number;
34
+ manifestPath: string;
35
+ };
36
+ // Watch diff/rerun state. Lives on the BrowserRuntime (one per set of
37
+ // per-project compilers, surviving controller re-entry that reuses the
38
+ // runtime) instead of module scope, so its lifetime always matches the
39
+ // compilers whose baselines it holds.
40
+ type BrowserWatchState = {
41
+ lastTestFiles: TestFileInfo[];
42
+ hooksEnabled: boolean;
43
+ // Diff baselines keyed per project: sibling projects have isolated
44
+ // compilers, so a shared flat baseline would let one project's compile
45
+ // clobber another's (missed reruns) and collide on compiler-local chunk
46
+ // keys.
47
+ invalidation: Map<string, WatchInvalidationState>;
48
+ // Affected files accumulated per project until a rerun drains them, so a
49
+ // compile finishing while another project's rerun is being planned cannot
50
+ // drop pending work.
51
+ pendingAffectedTestFiles: Map<string, Set<string>>;
52
+ // Per-project compile start times and the accumulated compile duration of
53
+ // the pending rerun, so the rerun's finalize reports the real buildTime.
54
+ compileStartTimes: Map<string, number>;
55
+ pendingBuildTimeMs: number;
56
+ };
57
+ export declare const drainPendingBuildTime: (watchState: BrowserWatchState) => number;
58
+ export declare const drainPendingAffectedTestFiles: (watchState: BrowserWatchState) => string[];
59
+ export type BrowserRuntime = {
60
+ // Per-project servers, keyed by project name.
61
+ projectServers: Map<string, BrowserProjectServer>;
62
+ // The server that hosts the container UI HTML (headed mode). The WebSocket
63
+ // server below is shared and reachable from any origin.
64
+ containerServer: BrowserProjectServer;
65
+ browser: BrowserProviderBrowser;
66
+ browserLaunchOptions: BrowserLaunchOptions;
67
+ wsPort: number;
68
+ tempDir: string;
69
+ containerPage?: BrowserProviderPage;
70
+ containerContext?: BrowserProviderContext;
71
+ setContainerOptions: (options: BrowserHostConfig) => void;
72
+ // Reserved extension seam for host-side dispatch capabilities.
73
+ dispatchHandlers: Map<string, BrowserDispatchHandler>;
74
+ wss: WebSocketServer;
75
+ rpcManager?: ContainerRpcManager;
76
+ projectEntries: BrowserProjectEntries[];
77
+ watchState: BrowserWatchState;
78
+ };
79
+ export declare const mapViewportByProject: (projects: BrowserProjectRuntime[]) => Map<string, {
80
+ width: number;
81
+ height: number;
82
+ }>;
83
+ export declare const createBrowserContextExcludeRegExp: (patterns: string[], projectRoot: string) => RegExp | null;
84
+ export declare const getBrowserProjects: (context: RstestContext) => ProjectContext[];
85
+ export declare const collectProjectEntries: (context: RstestContext, // The explicit browser-project subset the executor was constructed with. Falls
86
+ // back to re-deriving from `context` for internal callers (e.g. the watch
87
+ // plugin) that do not carry the plan's project list.
88
+ browserProjects?: ProjectContext[]) => Promise<BrowserProjectEntries[]>;
89
+ export declare const resolveContainerDist: () => string;
90
+ // Host-side mirror of the browser runtime's `toContextKey` (client/entry.ts):
91
+ // `./<path-relative-to-project-root>` with forward slashes. The runtime derives
92
+ // the same key from the target test file, so the non-watch import map below must
93
+ // key by the identical form for `loadTest(key)` to resolve.
94
+ export declare const toContextKey: (filePath: string, projectRootPosix: string) => string;
95
+ export declare const destroyBrowserRuntime: (runtime: BrowserRuntime) => Promise<void>;
96
+ export declare const createBrowserRuntime: ({ context, projectEntries: initialProjectEntries, browserProjects, shardedEntries, freezeShardedEntries, tempDir, isWatchMode, onTriggerRerun, containerDistPath, containerDevServer, forceHeadless, skipProviderLaunch, appliedModifyRstestConfigEnvironments }: {
97
+ context: RstestContext;
98
+ projectEntries: BrowserProjectEntries[];
99
+ /**
100
+ * The explicit browser-project subset (plan output). Drives launch-option
101
+ * consistency and the container origin (`browserProjects[0]`).
102
+ */ browserProjects: ProjectContext[];
103
+ shardedEntries?: Map<string, {
104
+ entries: Record<string, string>;
105
+ }>;
106
+ freezeShardedEntries?: boolean;
107
+ tempDir: string;
108
+ isWatchMode: boolean;
109
+ onTriggerRerun?: () => Promise<void>;
110
+ containerDistPath?: string;
111
+ containerDevServer?: string;
112
+ /** Force headless mode regardless of user config (used for list command) */ forceHeadless?: boolean;
113
+ skipProviderLaunch?: boolean;
114
+ appliedModifyRstestConfigEnvironments?: Set<string>;
115
+ }) => Promise<BrowserRuntime>;
116
+ export declare function resolveProjectEntries(context: RstestContext, shardedEntries: Map<string, {
117
+ entries: Record<string, string>;
118
+ }> | undefined, browserProjects: ProjectContext[]): Promise<BrowserProjectEntries[]>;
119
+ export { };
@@ -0,0 +1,52 @@
1
+ import { type TestResult } from '@rstest/core/internal/browser';
2
+ import { type BirpcReturn } from 'birpc';
3
+ import { type WebSocket, WebSocketServer } from 'ws';
4
+ import type { BrowserDispatchRequest, BrowserDispatchResponse, BrowserHostConfig, TestFileInfo } from './protocol.js';
5
+ import type { FatalPayload, HeadedTestFileCompletePayload, LogPayload, ReloadTestFileAck, TestFileStartPayload } from './hostPayloads.js';
6
+ /** RPC methods exposed by the host (server) to the container (client) */ export type HostRpcMethods = {
7
+ rerunTest: (testFile: string, testNamePattern?: string) => Promise<void>;
8
+ getTestFiles: () => Promise<TestFileInfo[]>;
9
+ onRunnerFramesReady: (testFiles: string[]) => Promise<void>;
10
+ // Test result callbacks from container
11
+ onTestFileStart: (payload: TestFileStartPayload) => Promise<void>;
12
+ onTestCaseResult: (payload: TestResult) => Promise<void>;
13
+ onTestFileComplete: (payload: HeadedTestFileCompletePayload) => Promise<void>;
14
+ onLog: (payload: LogPayload) => Promise<void>;
15
+ onFatal: (payload: FatalPayload) => Promise<void>;
16
+ // Generic dispatch endpoint used by runner RPC requests.
17
+ dispatch: (request: BrowserDispatchRequest) => Promise<BrowserDispatchResponse>;
18
+ };
19
+ /** RPC methods exposed by the container (client) to the host (server) */ export type ContainerRpcMethods = {
20
+ onTestFileUpdate: (testFiles: TestFileInfo[]) => Promise<void>;
21
+ reloadTestFile: (testFile: string, testNamePattern?: string) => Promise<ReloadTestFileAck>;
22
+ /**
23
+ * Replace the container's copy of the host config so runner iframes loaded
24
+ * from now on receive fresh values (e.g. the 'u' shortcut flipping
25
+ * `snapshot.updateSnapshot` between watch reruns).
26
+ */ onHostConfigUpdate: (config: BrowserHostConfig) => Promise<void>;
27
+ };
28
+ export type ContainerRpc = BirpcReturn<ContainerRpcMethods, HostRpcMethods>;
29
+ // ============================================================================
30
+ // RPC Manager - Encapsulates WebSocket and birpc management
31
+ // ============================================================================
32
+ /**
33
+ * Manages the WebSocket connection and birpc communication with the container UI.
34
+ * Provides a clean interface for sending RPC calls and handling connections.
35
+ */ export declare class ContainerRpcManager {
36
+ private wss;
37
+ private ws;
38
+ private rpc;
39
+ private methods;
40
+ private onDisconnect?;
41
+ private detachActiveSocketListeners;
42
+ constructor(wss: WebSocketServer, methods: HostRpcMethods, onDisconnect?: (error: Error) => void);
43
+ /** Update the RPC methods (used when starting a new test run) */ updateMethods(methods: HostRpcMethods, onDisconnect?: (error: Error) => void): void;
44
+ private setupConnectionHandler;
45
+ private attachWebSocket;
46
+ /** Check if a container is currently connected */ get isConnected(): boolean;
47
+ /** Get the current WebSocket instance (for reuse in watch mode) */ get currentWebSocket(): WebSocket | null;
48
+ /** Reattach an existing WebSocket (for watch mode reuse) */ reattach(ws: WebSocket): void;
49
+ /** Notify container of test file changes */ notifyTestFileUpdate(files: TestFileInfo[]): Promise<void>;
50
+ /** Push a refreshed host config to the container (watch reruns) */ updateHostConfig(config: BrowserHostConfig): Promise<void>;
51
+ /** Request container to reload a specific test file */ reloadTestFile(testFile: string, testNamePattern?: string): Promise<ReloadTestFileAck>;
52
+ }
@@ -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,58 @@
1
+ import type { RstestContext, TestFileResult, TestResult } from '@rstest/core/internal/browser';
2
+ import { type BrowserRuntime } from './browserRsbuild.js';
3
+ import type { HostDispatchRouter } from './dispatchRouter.js';
4
+ import { type FatalPayload, type LogPayload, type TestFileStartPayload } from './hostPayloads.js';
5
+ import type { BrowserHostConfig, TestFileInfo } from './protocol.js';
6
+ import { planWatchRerun } from './watchRerunPlanner.js';
7
+ import type { BrowserWatchSession, DispatchPageResolver, SchedulerRunResult } from './schedulerSeam.js';
8
+ import type { WatchSignals } from './watchSignals.js';
9
+ type HeadedSchedulerContext = Pick<RstestContext, 'rootPath' | 'snapshotManager' | 'updateReporterResultState'> & {
10
+ normalizedConfig: Pick<RstestContext['normalizedConfig'], 'name'>;
11
+ };
12
+ type HeadedSchedulerDeps = {
13
+ context: HeadedSchedulerContext;
14
+ runtime: BrowserRuntime;
15
+ allTestFiles: TestFileInfo[];
16
+ hostOptions: BrowserHostConfig;
17
+ isWatchMode: boolean;
18
+ createDispatchRouter: () => HostDispatchRouter;
19
+ handlers: {
20
+ handleTestFileStart: (payload: TestFileStartPayload) => Promise<void>;
21
+ handleTestCaseResult: (payload: TestResult) => Promise<void>;
22
+ handleTestFileComplete: (payload: TestFileResult) => Promise<void>;
23
+ handleLog: (payload: LogPayload) => Promise<void>;
24
+ handleFatal: (payload: FatalPayload) => Promise<void>;
25
+ };
26
+ fatalErrorRef: {
27
+ current: Error | null;
28
+ };
29
+ watchSignals: Pick<WatchSignals, 'setDispatchRerun' | 'signalInvalidation' | 'awaitSignalledCycle'>;
30
+ setDispatchPageResolver: (resolver: DispatchPageResolver) => void;
31
+ createWatchSession: (execute: (testPaths: string[]) => Promise<void>) => 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, isWatchMode, createDispatchRouter, handlers: { handleTestFileStart, handleTestCaseResult, handleTestFileComplete, handleLog, handleFatal }, fatalErrorRef, watchSignals, setDispatchPageResolver, createWatchSession, collectProjectEntries, logWatchReady, destroyRuntime }: HeadedSchedulerDeps) => Promise<SchedulerRunResult>;
58
+ export { };
@@ -0,0 +1,37 @@
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 { BrowserWatchSession, DispatchPageResolver, SchedulerRunResult } from './schedulerSeam.js';
10
+ import type { WatchSignals } from './watchSignals.js';
11
+ type HeadlessSchedulerContext = Pick<RstestContext, 'command' | '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
+ allTestFiles: TestFileInfo[];
20
+ projectRuntimeConfigs: BrowserProjectRuntime[];
21
+ hostOptions: BrowserHostConfig;
22
+ watchState: BrowserRuntime['watchState'];
23
+ isWatchMode: boolean;
24
+ createDispatchRouter: (options?: HostDispatchRouterOptions) => HostDispatchRouter;
25
+ handlers: {
26
+ handleFatal: (payload: FatalPayload) => Promise<void>;
27
+ handleTestFileComplete: (payload: TestFileResult) => Promise<void>;
28
+ };
29
+ watchSignals: Pick<WatchSignals, 'setDispatchRerun' | 'setInterrupt' | 'signalInvalidation'>;
30
+ setDispatchPageResolver: (resolver: DispatchPageResolver) => void;
31
+ createWatchSession: (execute: (testPaths: string[]) => Promise<void>) => BrowserWatchSession;
32
+ collectProjectEntries: () => Promise<Parameters<typeof planWatchRerun>[0]['projectEntries']>;
33
+ logWatchReady: () => void;
34
+ destroyRuntime: () => Promise<void>;
35
+ };
36
+ export declare const createHeadlessScheduler: ({ context, browser, browserLaunchOptions, projectServers, allTestFiles, projectRuntimeConfigs, hostOptions, watchState, isWatchMode, createDispatchRouter, handlers: { handleFatal, handleTestFileComplete }, watchSignals, setDispatchPageResolver, createWatchSession, collectProjectEntries, logWatchReady, destroyRuntime }: HeadlessSchedulerDeps) => Promise<SchedulerRunResult>;
37
+ export { };
@@ -1,51 +1,17 @@
1
- import { type BrowserTestRunOptions, type BrowserTestRunResult, type ListBrowserTestsOptions, type ListCommandResult, type RstestContext } from '@rstest/core/internal/browser';
2
- type LazyCompilationModule = {
3
- nameForCondition?: () => string | null | undefined;
4
- };
5
- type BrowserLazyCompilationConfig = {
6
- imports: true;
7
- entries: false;
8
- test?: (module: LazyCompilationModule) => boolean;
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
- * Resolve the actual port the dev server is listening on.
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 createBrowserContextExcludeRegExp: (patterns: string[], projectRoot: string) => RegExp | null;
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,30 @@
1
+ import type { Reporter, TestFileResult } 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 ReloadTestFileAck = {
18
+ runId: string;
19
+ };
20
+ export type HeadedTestFileCompletePayload = TestFileResult & {
21
+ runId?: string;
22
+ };
23
+ export type DeferredPromise<T> = {
24
+ promise: Promise<T>;
25
+ resolve: (value: T | PromiseLike<T>) => void;
26
+ reject: (reason?: unknown) => void;
27
+ };
28
+ export declare const getFileTaskId: (testPath: string) => string;
29
+ export declare const toError: (error: unknown) => Error;
30
+ export declare const createDeferredPromise: <T>() => DeferredPromise<T>;