@vitest/browser 3.0.0-beta.2 → 3.0.0-beta.4
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/context.d.ts +36 -0
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-BC8TFRpg.js +52 -0
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{orchestrator-DnP17K36.js → orchestrator-Cv-bzUFk.js} +8 -6
- package/dist/client/__vitest_browser__/{tester-BdwA4c5U.js → tester-DreAh6ar.js} +84 -61
- package/dist/client/__vitest_browser__/{utils-Owv5OOOf.js → utils-CaCTRFti.js} +2 -0
- package/dist/client/esm-client-injector.js +1 -1
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +6 -6
- package/dist/context.js +25 -4
- package/dist/{index-CMAn5ZST.js → index-Dos_sf7B.js} +10 -1
- package/dist/index.d.ts +52 -34
- package/dist/index.js +2437 -1970
- package/dist/locators/index.d.ts +3 -0
- package/dist/locators/index.js +1 -1
- package/dist/locators/playwright.js +1 -1
- package/dist/locators/preview.js +1 -1
- package/dist/locators/webdriverio.js +1 -1
- package/dist/providers.js +3 -3
- package/dist/state.js +1 -1
- package/dist/{webdriver-JzwxG3Ek.js → webdriver-dkCg9pjp.js} +22 -22
- package/jest-dom.d.ts +4 -4
- package/package.json +15 -15
- package/providers/playwright.d.ts +2 -1
- package/providers/webdriverio.d.ts +2 -1
- package/dist/client/__vitest__/assets/index-BgsOOCCp.js +0 -52
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Plugin } from 'vitest/config';
|
|
2
|
-
import { CDPSession, BrowserServerState as BrowserServerState$1,
|
|
3
|
-
import * as
|
|
4
|
-
import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff } from 'vitest';
|
|
2
|
+
import { CDPSession, BrowserServerState as BrowserServerState$1, ProjectBrowser as ProjectBrowser$1, TestProject, BrowserProvider, Vitest, ResolvedConfig, Vite, BrowserCommand, BrowserScript, ProcessPool } from 'vitest/node';
|
|
3
|
+
import * as vite from 'vite';
|
|
5
4
|
import { HtmlTagDescriptor } from 'vite';
|
|
5
|
+
import * as vitest from 'vitest';
|
|
6
|
+
import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
|
|
6
7
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
7
8
|
import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
|
|
8
9
|
|
|
@@ -26,6 +27,7 @@ interface WebSocketBrowserHandlers {
|
|
|
26
27
|
resolveSnapshotPath: (testPath: string) => string;
|
|
27
28
|
resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
|
|
28
29
|
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
30
|
+
onQueued: (file: RunnerTestFile) => void;
|
|
29
31
|
onCollected: (files?: RunnerTestFile[]) => Promise<void>;
|
|
30
32
|
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
31
33
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
@@ -35,11 +37,11 @@ interface WebSocketBrowserHandlers {
|
|
|
35
37
|
saveSnapshotFile: (id: string, content: string) => Promise<void>;
|
|
36
38
|
removeSnapshotFile: (id: string) => Promise<void>;
|
|
37
39
|
sendLog: (log: UserConsoleLog) => void;
|
|
38
|
-
finishBrowserTests: (
|
|
40
|
+
finishBrowserTests: (sessionId: string) => void;
|
|
39
41
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
40
42
|
debug: (...args: string[]) => void;
|
|
41
43
|
resolveId: (id: string, importer?: string) => Promise<ServerIdResolution | null>;
|
|
42
|
-
triggerCommand: <T>(
|
|
44
|
+
triggerCommand: <T>(sessionId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
|
|
43
45
|
resolveMock: (id: string, importer: string, options: {
|
|
44
46
|
mock: 'spy' | 'factory' | 'auto';
|
|
45
47
|
}) => Promise<ServerMockResolution>;
|
|
@@ -47,8 +49,8 @@ interface WebSocketBrowserHandlers {
|
|
|
47
49
|
getBrowserFileSourceMap: (id: string) => SourceMap | null | {
|
|
48
50
|
mappings: '';
|
|
49
51
|
} | undefined;
|
|
50
|
-
sendCdpEvent: (
|
|
51
|
-
trackCdpEvent: (
|
|
52
|
+
sendCdpEvent: (sessionId: string, event: string, payload?: Record<string, unknown>) => unknown;
|
|
53
|
+
trackCdpEvent: (sessionId: string, type: 'on' | 'once' | 'off', event: string, listenerId: string) => void;
|
|
52
54
|
}
|
|
53
55
|
interface WebSocketBrowserEvents {
|
|
54
56
|
onCancel: (reason: CancelReason) => void;
|
|
@@ -82,52 +84,68 @@ declare class BrowserServerCDPHandler {
|
|
|
82
84
|
declare class BrowserServerState implements BrowserServerState$1 {
|
|
83
85
|
readonly orchestrators: Map<string, WebSocketBrowserRPC>;
|
|
84
86
|
readonly testers: Map<string, WebSocketBrowserRPC>;
|
|
85
|
-
readonly cdps: Map<string, BrowserServerCDPHandler>;
|
|
86
|
-
private contexts;
|
|
87
|
-
getContext(contextId: string): BrowserServerStateContext | undefined;
|
|
88
|
-
createAsyncContext(method: 'run' | 'collect', contextId: string, files: string[]): Promise<void>;
|
|
89
|
-
removeCDPHandler(sessionId: string): Promise<void>;
|
|
90
87
|
}
|
|
91
88
|
|
|
92
|
-
declare class
|
|
89
|
+
declare class ProjectBrowser implements ProjectBrowser$1 {
|
|
90
|
+
project: TestProject;
|
|
91
|
+
base: string;
|
|
92
|
+
testerHtml: Promise<string> | string;
|
|
93
|
+
testerFilepath: string;
|
|
94
|
+
locatorsUrl: string | undefined;
|
|
95
|
+
provider: BrowserProvider;
|
|
96
|
+
vitest: Vitest;
|
|
97
|
+
config: ResolvedConfig;
|
|
98
|
+
children: Set<ProjectBrowser>;
|
|
99
|
+
parent: ParentBrowserProject;
|
|
100
|
+
state: BrowserServerState;
|
|
101
|
+
constructor(project: TestProject, base: string);
|
|
102
|
+
get vite(): vite.ViteDevServer;
|
|
103
|
+
wrapSerializedConfig(): SerializedConfig;
|
|
104
|
+
initBrowserProvider(project: TestProject): Promise<void>;
|
|
105
|
+
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
106
|
+
parseStacktrace(trace: string, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
107
|
+
close(): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare class ParentBrowserProject {
|
|
93
111
|
project: TestProject;
|
|
94
112
|
base: string;
|
|
95
|
-
faviconUrl: string;
|
|
96
|
-
prefixTesterUrl: string;
|
|
97
113
|
orchestratorScripts: string | undefined;
|
|
98
114
|
testerScripts: HtmlTagDescriptor[] | undefined;
|
|
115
|
+
faviconUrl: string;
|
|
116
|
+
prefixTesterUrl: string;
|
|
99
117
|
manifest: Promise<Vite.Manifest> | Vite.Manifest;
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
vite: Vite.ViteDevServer;
|
|
119
|
+
private stackTraceOptions;
|
|
102
120
|
orchestratorHtml: Promise<string> | string;
|
|
103
121
|
injectorJs: Promise<string> | string;
|
|
104
122
|
errorCatcherUrl: string;
|
|
105
123
|
locatorsUrl: string | undefined;
|
|
106
124
|
stateJs: Promise<string> | string;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
commands: Record<string, BrowserCommand<any>>;
|
|
126
|
+
children: Set<ProjectBrowser>;
|
|
127
|
+
vitest: Vitest;
|
|
128
|
+
config: ResolvedConfig;
|
|
111
129
|
constructor(project: TestProject, base: string);
|
|
112
|
-
setServer(
|
|
113
|
-
|
|
130
|
+
setServer(vite: Vite.ViteDevServer): void;
|
|
131
|
+
spawn(project: TestProject): ProjectBrowser;
|
|
132
|
+
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
|
|
133
|
+
parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
|
|
134
|
+
readonly cdps: Map<string, BrowserServerCDPHandler>;
|
|
135
|
+
private cdpSessionsPromises;
|
|
136
|
+
ensureCDPHandler(sessionId: string, rpcId: string): Promise<BrowserServerCDPHandler>;
|
|
137
|
+
removeCDPHandler(sessionId: string): void;
|
|
138
|
+
formatScripts(scripts: BrowserScript[] | undefined): Promise<HtmlTagDescriptor[]>;
|
|
114
139
|
resolveTesterUrl(pathname: string): {
|
|
115
|
-
|
|
140
|
+
sessionId: string;
|
|
116
141
|
testFile: string;
|
|
117
142
|
};
|
|
118
|
-
formatScripts(scripts: BrowserScript[] | undefined): Promise<HtmlTagDescriptor[]>;
|
|
119
|
-
initBrowserProvider(): Promise<void>;
|
|
120
|
-
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
121
|
-
parseStacktrace(trace: string, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
122
|
-
private cdpSessionsPromises;
|
|
123
|
-
ensureCDPHandler(contextId: string, sessionId: string): Promise<BrowserServerCDPHandler>;
|
|
124
|
-
close(): Promise<void>;
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
declare const distRoot: string;
|
|
128
146
|
|
|
129
|
-
declare function createBrowserPool(
|
|
147
|
+
declare function createBrowserPool(vitest: Vitest): ProcessPool;
|
|
130
148
|
|
|
131
|
-
declare function createBrowserServer(project: TestProject, configFile: string | undefined, prePlugins?: Plugin[], postPlugins?: Plugin[]): Promise<
|
|
149
|
+
declare function createBrowserServer(project: TestProject, configFile: string | undefined, prePlugins?: Plugin[], postPlugins?: Plugin[]): Promise<ParentBrowserProject>;
|
|
132
150
|
|
|
133
|
-
export {
|
|
151
|
+
export { ProjectBrowser, createBrowserPool, createBrowserServer, distRoot };
|