@rstest/browser 0.7.9

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.
@@ -0,0 +1 @@
1
+ /*! For license information please see lib-react.a9c9a89b.js.LICENSE.txt */
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Rstest Browser Test Runner</title>
7
+ <script>
8
+ window.__RSTEST_BROWSER_OPTIONS__ = __RSTEST_OPTIONS_PLACEHOLDER__;
9
+ </script>
10
+ <script defer src="/container-static/js/lib-react.a9c9a89b.js"></script><script defer src="/container-static/js/916.5aee8d2f.js"></script><script defer src="/container-static/js/container.5ddd46c3.js"></script><link href="/container-static/css/container.dc438e35.css" rel="stylesheet"></head>
11
+ <body>
12
+ <div id="root"></div>
13
+ </body>
14
+ </html>
@@ -0,0 +1,7 @@
1
+ import type { BrowserClientMessage, BrowserHostConfig } from '../protocol';
2
+ declare global {
3
+ interface Window {
4
+ __RSTEST_BROWSER_OPTIONS__?: BrowserHostConfig;
5
+ __rstest_dispatch__?: (message: BrowserClientMessage) => void;
6
+ }
7
+ }
@@ -0,0 +1,25 @@
1
+ export type FakeTimerInstallOpts = Record<string, unknown>;
2
+ export type FakeTimerWithContext = {
3
+ timers: Record<string, unknown>;
4
+ };
5
+ export type InstalledClock = {
6
+ now: number;
7
+ reset: () => void;
8
+ uninstall: () => void;
9
+ runAll: () => void;
10
+ runAllAsync: () => Promise<void>;
11
+ runToLast: () => void;
12
+ runToLastAsync: () => Promise<void>;
13
+ tick: (ms: number) => void;
14
+ tickAsync: (ms: number) => Promise<void>;
15
+ next: () => void;
16
+ nextAsync: () => Promise<void>;
17
+ runToFrame: () => void;
18
+ runMicrotasks: () => void;
19
+ setSystemTime: (now?: number | Date) => void;
20
+ countTimers: () => number;
21
+ };
22
+ export declare const withGlobal: (_global: typeof globalThis) => {
23
+ timers: {};
24
+ install: (_config?: FakeTimerInstallOpts) => InstalledClock;
25
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Re-export runtime API from @rstest/core/browser-runtime for browser use.
3
+ * This file is used as an alias target for '@rstest/core' in browser mode.
4
+ *
5
+ * Uses @rstest/core/browser-runtime which only exports the test APIs
6
+ * (describe, it, expect, etc.) without any Node.js dependencies.
7
+ */
8
+ export type { Assertion, Mock } from '@rstest/core';
9
+ export * from '@rstest/core/browser-runtime';
@@ -0,0 +1,35 @@
1
+ import type { BrowserHostConfig } from '../protocol';
2
+ declare global {
3
+ interface Window {
4
+ __RSTEST_BROWSER_OPTIONS__?: BrowserHostConfig;
5
+ }
6
+ }
7
+ /**
8
+ * Browser snapshot environment that proxies file operations to the host
9
+ * via postMessage RPC through the container.
10
+ */
11
+ export declare class BrowserSnapshotEnvironment {
12
+ getVersion(): string;
13
+ getHeader(): string;
14
+ resolveRawPath(_testPath: string, rawPath: string): Promise<string>;
15
+ resolvePath(filepath: string): Promise<string>;
16
+ prepareDirectory(): Promise<void>;
17
+ saveSnapshotFile(filepath: string, snapshot: string): Promise<void>;
18
+ readSnapshotFile(filepath: string): Promise<string | null>;
19
+ removeSnapshotFile(filepath: string): Promise<void>;
20
+ /**
21
+ * Process stack trace for inline snapshots.
22
+ * Maps bundled URLs back to original source file paths.
23
+ */
24
+ processStackTrace(stack: {
25
+ file: string;
26
+ line: number;
27
+ column: number;
28
+ method: string;
29
+ }): {
30
+ file: string;
31
+ line: number;
32
+ column: number;
33
+ method: string;
34
+ };
35
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Get all script URLs currently on the page.
3
+ * Used to detect newly loaded chunk scripts.
4
+ */
5
+ export declare const getScriptUrls: () => Set<string>;
6
+ /**
7
+ * Find the newly added script URL by comparing script sets.
8
+ * Returns the first new script URL found, or null if none.
9
+ */
10
+ export declare const findNewScriptUrl: (beforeUrls: Set<string>, afterUrls: Set<string>) => string | null;
11
+ /**
12
+ * Preload source map for a test file's chunk URL.
13
+ *
14
+ * Always fetches fresh source map to handle file changes during watch mode.
15
+ *
16
+ * @param chunkUrl - The full URL of the chunk JS file
17
+ */
18
+ export declare const preloadTestFileSourceMap: (chunkUrl: string) => Promise<void>;
19
+ /**
20
+ * Preload source map for the runner.js file.
21
+ *
22
+ * This is essential for inline snapshot support because the snapshot code
23
+ * runs in runner.js (which contains @rstest/core/browser-runtime).
24
+ * Without this, stack traces from inline snapshots cannot be mapped back
25
+ * to the original source files.
26
+ */
27
+ export declare const preloadRunnerSourceMap: () => Promise<void>;
28
+ /**
29
+ * Clear cache (for testing purposes)
30
+ */
31
+ export declare const clearCache: () => void;
32
+ /**
33
+ * Stack frame interface matching @vitest/snapshot's format
34
+ */
35
+ export interface StackFrame {
36
+ file: string;
37
+ line: number;
38
+ column: number;
39
+ method?: string;
40
+ }
41
+ /**
42
+ * Map a stack frame from bundled URL to original source file.
43
+ * This is used by BrowserSnapshotEnvironment.processStackTrace
44
+ */
45
+ export declare const mapStackFrame: (frame: StackFrame) => StackFrame;
@@ -0,0 +1,17 @@
1
+ import { type ListCommandResult, type Rstest } from '@rstest/core/browser';
2
+ export declare const runBrowserController: (context: Rstest) => Promise<void>;
3
+ /**
4
+ * Result from collecting browser tests.
5
+ * This is the return type for listBrowserTests, designed for future extraction
6
+ * to a separate browser package.
7
+ */
8
+ export type ListBrowserTestsResult = {
9
+ list: ListCommandResult[];
10
+ close: () => Promise<void>;
11
+ };
12
+ /**
13
+ * Collect test metadata from browser mode projects without running them.
14
+ * This function creates a headless browser runtime, loads test files,
15
+ * and collects their test structure (describe/test declarations).
16
+ */
17
+ export declare const listBrowserTests: (context: Rstest) => Promise<ListBrowserTestsResult>;
@@ -0,0 +1,5 @@
1
+ import type { Rstest } from '@rstest/core/browser';
2
+ import { type ListBrowserTestsResult } from './hostController';
3
+ export declare function runBrowserTests(context: Rstest): Promise<void>;
4
+ export declare function listBrowserTests(context: Rstest): Promise<ListBrowserTestsResult>;
5
+ export type { ListBrowserTestsResult };