@vitest/browser 2.0.0-beta.9 → 2.0.1
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 +167 -14
- package/context.js +2 -0
- package/dist/client/.vite/manifest.json +9 -9
- package/dist/client/__vitest__/assets/index-CAY_OcEp.js +52 -0
- package/dist/client/__vitest__/assets/index-DEM1IsBG.css +1 -0
- package/dist/client/__vitest__/index.html +16 -11
- package/dist/client/__vitest_browser__/{rpc-DBukiZYG.js → client-dLyjuL0K.js} +156 -174
- package/dist/client/__vitest_browser__/orchestrator-x0A1t8rC.js +369 -0
- package/dist/client/__vitest_browser__/tester-BdcP5piS.js +12070 -0
- package/dist/client/esm-client-injector.js +21 -18
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/{tester.html → tester/tester.html} +12 -3
- package/dist/context.js +206 -0
- package/dist/index.d.ts +128 -4
- package/dist/index.js +2074 -457
- package/dist/providers.js +16 -112
- package/dist/state.js +1 -0
- package/dist/webdriver-BdVqnfdE.js +249 -0
- package/jest-dom.d.ts +816 -0
- package/matchers.d.ts +22 -0
- package/package.json +20 -12
- package/providers/playwright.d.ts +60 -2
- package/providers/webdriverio.d.ts +5 -0
- package/dist/client/__vitest__/assets/index-BZPCs_Bg.js +0 -51
- package/dist/client/__vitest__/assets/index-DrQA2UkS.css +0 -1
- package/dist/client/__vitest_browser__/orchestrator-CTfJ7g35.js +0 -186
- package/dist/client/__vitest_browser__/tester-Bo1gw1oi.js +0 -696
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
const moduleCache = new Map()
|
|
1
|
+
const moduleCache = new Map();
|
|
2
2
|
|
|
3
3
|
function wrapModule(module) {
|
|
4
|
-
if (typeof module ===
|
|
4
|
+
if (typeof module === "function") {
|
|
5
5
|
const promise = new Promise((resolve, reject) => {
|
|
6
|
-
if (typeof __vitest_mocker__ ===
|
|
7
|
-
return module().then(resolve, reject)
|
|
6
|
+
if (typeof __vitest_mocker__ === "undefined")
|
|
7
|
+
return module().then(resolve, reject);
|
|
8
8
|
__vitest_mocker__.prepare().finally(() => {
|
|
9
|
-
module().then(resolve, reject)
|
|
10
|
-
})
|
|
11
|
-
})
|
|
12
|
-
moduleCache.set(promise, { promise, evaluated: false })
|
|
13
|
-
return promise.finally(() => moduleCache.delete(promise))
|
|
9
|
+
module().then(resolve, reject);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
moduleCache.set(promise, { promise, evaluated: false });
|
|
13
|
+
return promise.finally(() => moduleCache.delete(promise));
|
|
14
14
|
}
|
|
15
|
-
return module
|
|
15
|
+
return module;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
window.__vitest_browser_runner__ = {
|
|
19
19
|
wrapModule,
|
|
20
20
|
moduleCache,
|
|
21
21
|
config: { __VITEST_CONFIG__ },
|
|
22
|
+
viteConfig: { __VITEST_VITE_CONFIG__ },
|
|
22
23
|
files: { __VITEST_FILES__ },
|
|
23
24
|
type: { __VITEST_TYPE__ },
|
|
24
|
-
}
|
|
25
|
+
contextId: { __VITEST_CONTEXT_ID__ },
|
|
26
|
+
provider: { __VITEST_PROVIDER__ },
|
|
27
|
+
providedContext: { __VITEST_PROVIDED_CONTEXT__ },
|
|
28
|
+
};
|
|
25
29
|
|
|
26
|
-
const config = __vitest_browser_runner__.config
|
|
30
|
+
const config = __vitest_browser_runner__.config;
|
|
27
31
|
|
|
28
32
|
if (config.testNamePattern)
|
|
29
|
-
config.testNamePattern = parseRegexp(config.testNamePattern)
|
|
33
|
+
config.testNamePattern = parseRegexp(config.testNamePattern);
|
|
30
34
|
|
|
31
35
|
function parseRegexp(input) {
|
|
32
36
|
// Parse input
|
|
33
|
-
const m = input.match(/(\/?)(.+)\1([a-z]*)/i)
|
|
37
|
+
const m = input.match(/(\/?)(.+)\1([a-z]*)/i);
|
|
34
38
|
|
|
35
39
|
// match nothing
|
|
36
|
-
if (!m)
|
|
37
|
-
return /$^/
|
|
40
|
+
if (!m) return /$^/;
|
|
38
41
|
|
|
39
42
|
// Invalid flags
|
|
40
43
|
if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3]))
|
|
41
|
-
return RegExp(input)
|
|
44
|
+
return RegExp(input);
|
|
42
45
|
|
|
43
46
|
// Create the regular expression
|
|
44
|
-
return new RegExp(m[2], m[3])
|
|
47
|
+
return new RegExp(m[2], m[3]);
|
|
45
48
|
}
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
</style>
|
|
26
26
|
<script>{__VITEST_INJECTOR__}</script>
|
|
27
27
|
{__VITEST_SCRIPTS__}
|
|
28
|
-
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-
|
|
29
|
-
<link rel="modulepreload" crossorigin href="/__vitest_browser__/
|
|
28
|
+
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-x0A1t8rC.js"></script>
|
|
29
|
+
<link rel="modulepreload" crossorigin href="/__vitest_browser__/client-dLyjuL0K.js">
|
|
30
30
|
</head>
|
|
31
31
|
<body>
|
|
32
32
|
<div id="vitest-tester"></div>
|
|
@@ -17,11 +17,20 @@
|
|
|
17
17
|
}
|
|
18
18
|
</style>
|
|
19
19
|
<script>{__VITEST_INJECTOR__}</script>
|
|
20
|
+
<script>{__VITEST_STATE__}</script>
|
|
20
21
|
{__VITEST_SCRIPTS__}
|
|
21
|
-
<script type="module" crossorigin src="/__vitest_browser__/tester-
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/__vitest_browser__/
|
|
22
|
+
<script type="module" crossorigin src="/__vitest_browser__/tester-BdcP5piS.js"></script>
|
|
23
|
+
<link rel="modulepreload" crossorigin href="/__vitest_browser__/client-dLyjuL0K.js">
|
|
23
24
|
</head>
|
|
24
|
-
<body
|
|
25
|
+
<body
|
|
26
|
+
data-vitest-body
|
|
27
|
+
style="
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
transform: scale(1);
|
|
31
|
+
transform-origin: left top;
|
|
32
|
+
"
|
|
33
|
+
>
|
|
25
34
|
{__VITEST_APPEND__}
|
|
26
35
|
</body>
|
|
27
36
|
</html>
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
const state = () => __vitest_worker__;
|
|
2
|
+
const runner = () => __vitest_browser_runner__;
|
|
3
|
+
function filepath() {
|
|
4
|
+
return state().filepath || state().current?.file?.filepath || void 0;
|
|
5
|
+
}
|
|
6
|
+
const rpc = () => state().rpc;
|
|
7
|
+
const contextId = runner().contextId;
|
|
8
|
+
const channel = new BroadcastChannel(`vitest:${contextId}`);
|
|
9
|
+
function triggerCommand(command, ...args) {
|
|
10
|
+
return rpc().triggerCommand(contextId, command, filepath(), args);
|
|
11
|
+
}
|
|
12
|
+
const provider = runner().provider;
|
|
13
|
+
function convertElementToCssSelector(element) {
|
|
14
|
+
if (!element || !(element instanceof Element)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Expected DOM element to be an instance of Element, received ${typeof element}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return getUniqueCssSelector(element);
|
|
20
|
+
}
|
|
21
|
+
function getUniqueCssSelector(el) {
|
|
22
|
+
const path = [];
|
|
23
|
+
let parent;
|
|
24
|
+
let hasShadowRoot = false;
|
|
25
|
+
while (parent = getParent(el)) {
|
|
26
|
+
if (parent.shadowRoot) {
|
|
27
|
+
hasShadowRoot = true;
|
|
28
|
+
}
|
|
29
|
+
const tag = el.tagName;
|
|
30
|
+
if (el.id) {
|
|
31
|
+
path.push(`#${el.id}`);
|
|
32
|
+
} else if (!el.nextElementSibling && !el.previousElementSibling) {
|
|
33
|
+
path.push(tag);
|
|
34
|
+
} else {
|
|
35
|
+
let index = 0;
|
|
36
|
+
let sameTagSiblings = 0;
|
|
37
|
+
let elementIndex = 0;
|
|
38
|
+
for (const sibling of parent.children) {
|
|
39
|
+
index++;
|
|
40
|
+
if (sibling.tagName === tag) {
|
|
41
|
+
sameTagSiblings++;
|
|
42
|
+
}
|
|
43
|
+
if (sibling === el) {
|
|
44
|
+
elementIndex = index;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (sameTagSiblings > 1) {
|
|
48
|
+
path.push(`${tag}:nth-child(${elementIndex})`);
|
|
49
|
+
} else {
|
|
50
|
+
path.push(tag);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
el = parent;
|
|
54
|
+
}
|
|
55
|
+
return `${provider === "webdriverio" && hasShadowRoot ? ">>>" : ""}${path.reverse().join(" > ")}`.toLowerCase();
|
|
56
|
+
}
|
|
57
|
+
function getParent(el) {
|
|
58
|
+
const parent = el.parentNode;
|
|
59
|
+
if (parent instanceof ShadowRoot) {
|
|
60
|
+
return parent.host;
|
|
61
|
+
}
|
|
62
|
+
return parent;
|
|
63
|
+
}
|
|
64
|
+
const userEvent = {
|
|
65
|
+
// TODO: actually setup userEvent with config options
|
|
66
|
+
setup() {
|
|
67
|
+
return userEvent;
|
|
68
|
+
},
|
|
69
|
+
click(element, options = {}) {
|
|
70
|
+
const css = convertElementToCssSelector(element);
|
|
71
|
+
return triggerCommand("__vitest_click", css, options);
|
|
72
|
+
},
|
|
73
|
+
dblClick(element, options = {}) {
|
|
74
|
+
const css = convertElementToCssSelector(element);
|
|
75
|
+
return triggerCommand("__vitest_dblClick", css, options);
|
|
76
|
+
},
|
|
77
|
+
tripleClick(element, options = {}) {
|
|
78
|
+
const css = convertElementToCssSelector(element);
|
|
79
|
+
return triggerCommand("__vitest_tripleClick", css, options);
|
|
80
|
+
},
|
|
81
|
+
selectOptions(element, value) {
|
|
82
|
+
const values = provider === "webdriverio" ? getWebdriverioSelectOptions(element, value) : getSimpleSelectOptions(element, value);
|
|
83
|
+
const css = convertElementToCssSelector(element);
|
|
84
|
+
return triggerCommand("__vitest_selectOptions", css, values);
|
|
85
|
+
},
|
|
86
|
+
type(element, text, options = {}) {
|
|
87
|
+
const css = convertElementToCssSelector(element);
|
|
88
|
+
return triggerCommand("__vitest_type", css, text, options);
|
|
89
|
+
},
|
|
90
|
+
clear(element) {
|
|
91
|
+
const css = convertElementToCssSelector(element);
|
|
92
|
+
return triggerCommand("__vitest_clear", css);
|
|
93
|
+
},
|
|
94
|
+
tab(options = {}) {
|
|
95
|
+
return triggerCommand("__vitest_tab", options);
|
|
96
|
+
},
|
|
97
|
+
keyboard(text) {
|
|
98
|
+
return triggerCommand("__vitest_keyboard", text);
|
|
99
|
+
},
|
|
100
|
+
hover(element) {
|
|
101
|
+
const css = convertElementToCssSelector(element);
|
|
102
|
+
return triggerCommand("__vitest_hover", css);
|
|
103
|
+
},
|
|
104
|
+
unhover(element) {
|
|
105
|
+
const css = convertElementToCssSelector(element.ownerDocument.body);
|
|
106
|
+
return triggerCommand("__vitest_hover", css);
|
|
107
|
+
},
|
|
108
|
+
// non userEvent events, but still useful
|
|
109
|
+
fill(element, text, options) {
|
|
110
|
+
const css = convertElementToCssSelector(element);
|
|
111
|
+
return triggerCommand("__vitest_fill", css, text, options);
|
|
112
|
+
},
|
|
113
|
+
dragAndDrop(source, target, options = {}) {
|
|
114
|
+
const sourceCss = convertElementToCssSelector(source);
|
|
115
|
+
const targetCss = convertElementToCssSelector(target);
|
|
116
|
+
return triggerCommand("__vitest_dragAndDrop", sourceCss, targetCss, options);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function getWebdriverioSelectOptions(element, value) {
|
|
120
|
+
const options = [...element.querySelectorAll("option")];
|
|
121
|
+
const arrayValues = Array.isArray(value) ? value : [value];
|
|
122
|
+
if (!arrayValues.length) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
if (arrayValues.length > 1) {
|
|
126
|
+
throw new Error(`Provider "webdriverio" doesn't support selecting multiple values at once`);
|
|
127
|
+
}
|
|
128
|
+
const optionValue = arrayValues[0];
|
|
129
|
+
if (typeof optionValue !== "string") {
|
|
130
|
+
const index = options.indexOf(optionValue);
|
|
131
|
+
if (index === -1) {
|
|
132
|
+
throw new Error(`The element ${convertElementToCssSelector(optionValue)} was not found in the "select" options.`);
|
|
133
|
+
}
|
|
134
|
+
return [{ index }];
|
|
135
|
+
}
|
|
136
|
+
const valueIndex = options.findIndex((option) => option.value === optionValue);
|
|
137
|
+
if (valueIndex !== -1) {
|
|
138
|
+
return [{ index: valueIndex }];
|
|
139
|
+
}
|
|
140
|
+
const labelIndex = options.findIndex(
|
|
141
|
+
(option) => option.textContent?.trim() === optionValue || option.ariaLabel === optionValue
|
|
142
|
+
);
|
|
143
|
+
if (labelIndex === -1) {
|
|
144
|
+
throw new Error(`The option "${optionValue}" was not found in the "select" options.`);
|
|
145
|
+
}
|
|
146
|
+
return [{ index: labelIndex }];
|
|
147
|
+
}
|
|
148
|
+
function getSimpleSelectOptions(element, value) {
|
|
149
|
+
return (Array.isArray(value) ? value : [value]).map((v) => {
|
|
150
|
+
if (typeof v !== "string") {
|
|
151
|
+
return { element: convertElementToCssSelector(v) };
|
|
152
|
+
}
|
|
153
|
+
return v;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function cdp() {
|
|
157
|
+
return runner().cdp;
|
|
158
|
+
}
|
|
159
|
+
const screenshotIds = {};
|
|
160
|
+
const page = {
|
|
161
|
+
get config() {
|
|
162
|
+
return runner().config;
|
|
163
|
+
},
|
|
164
|
+
viewport(width, height) {
|
|
165
|
+
const id = runner().iframeId;
|
|
166
|
+
channel.postMessage({ type: "viewport", width, height, id });
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
channel.addEventListener("message", function handler(e) {
|
|
169
|
+
if (e.data.type === "viewport:done" && e.data.id === id) {
|
|
170
|
+
channel.removeEventListener("message", handler);
|
|
171
|
+
resolve();
|
|
172
|
+
}
|
|
173
|
+
if (e.data.type === "viewport:fail" && e.data.id === id) {
|
|
174
|
+
channel.removeEventListener("message", handler);
|
|
175
|
+
reject(new Error(e.data.error));
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
async screenshot(options = {}) {
|
|
181
|
+
const currentTest = state().current;
|
|
182
|
+
if (!currentTest) {
|
|
183
|
+
throw new Error("Cannot take a screenshot outside of a test.");
|
|
184
|
+
}
|
|
185
|
+
if (currentTest.concurrent) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
"Cannot take a screenshot in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment. Use a non-concurrent test to take a screenshot."
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const repeatCount = currentTest.result?.repeatCount ?? 0;
|
|
191
|
+
const taskName = getTaskFullName(currentTest);
|
|
192
|
+
const number = screenshotIds[repeatCount]?.[taskName] ?? 1;
|
|
193
|
+
screenshotIds[repeatCount] ??= {};
|
|
194
|
+
screenshotIds[repeatCount][taskName] = number + 1;
|
|
195
|
+
const name = options.path || `${taskName.replace(/[^a-z0-9]/gi, "-")}-${number}.png`;
|
|
196
|
+
return triggerCommand("__vitest_screenshot", name, {
|
|
197
|
+
...options,
|
|
198
|
+
element: options.element ? convertElementToCssSelector(options.element) : void 0
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
function getTaskFullName(task) {
|
|
203
|
+
return task.suite ? `${getTaskFullName(task.suite)} ${task.name}` : task.name;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { cdp, page, userEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,131 @@
|
|
|
1
|
-
import { WorkspaceProject } from 'vitest/node';
|
|
2
|
-
export { BrowserCommand } from 'vitest/node';
|
|
1
|
+
import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, WorkspaceProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node';
|
|
3
2
|
import { Plugin } from 'vitest/config';
|
|
3
|
+
import * as vitest from 'vitest';
|
|
4
|
+
import { File, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, ResolvedConfig } from 'vitest';
|
|
5
|
+
import { ErrorWithDiff } from '@vitest/utils';
|
|
6
|
+
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
9
|
+
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
10
|
+
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
11
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
12
|
+
/**
|
|
13
|
+
* Send event without asking for response
|
|
14
|
+
*/
|
|
15
|
+
asEvent: (...args: ArgumentsType<T>) => void;
|
|
16
|
+
};
|
|
17
|
+
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
18
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
19
|
+
} & {
|
|
20
|
+
$functions: LocalFunctions;
|
|
21
|
+
};
|
|
6
22
|
|
|
7
|
-
|
|
23
|
+
interface WebSocketBrowserHandlers {
|
|
24
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
25
|
+
resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
|
|
26
|
+
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
27
|
+
onCollected: (files?: File[]) => Promise<void>;
|
|
28
|
+
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
29
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
30
|
+
onCancel: (reason: CancelReason) => void;
|
|
31
|
+
getCountOfFailedTests: () => number;
|
|
32
|
+
readSnapshotFile: (id: string) => Promise<string | null>;
|
|
33
|
+
saveSnapshotFile: (id: string, content: string) => Promise<void>;
|
|
34
|
+
removeSnapshotFile: (id: string) => Promise<void>;
|
|
35
|
+
sendLog: (log: UserConsoleLog) => void;
|
|
36
|
+
finishBrowserTests: (contextId: string) => void;
|
|
37
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
38
|
+
debug: (...args: string[]) => void;
|
|
39
|
+
resolveId: (id: string, importer?: string) => Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
} | null>;
|
|
42
|
+
triggerCommand: <T>(contextId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
|
|
43
|
+
resolveMock: (id: string, importer: string, hasFactory: boolean) => Promise<{
|
|
44
|
+
type: 'factory' | 'redirect' | 'automock';
|
|
45
|
+
mockPath?: string | null;
|
|
46
|
+
resolvedId: string;
|
|
47
|
+
needsInterop?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
invalidate: (ids: string[]) => void;
|
|
50
|
+
getBrowserFileSourceMap: (id: string) => SourceMap | null | {
|
|
51
|
+
mappings: '';
|
|
52
|
+
} | undefined;
|
|
53
|
+
sendCdpEvent: (contextId: string, event: string, payload?: Record<string, unknown>) => unknown;
|
|
54
|
+
trackCdpEvent: (contextId: string, type: 'on' | 'once' | 'off', event: string, listenerId: string) => void;
|
|
55
|
+
}
|
|
56
|
+
interface WebSocketBrowserEvents {
|
|
57
|
+
onCancel: (reason: CancelReason) => void;
|
|
58
|
+
createTesters: (files: string[]) => Promise<void>;
|
|
59
|
+
cdpEvent: (event: string, payload: unknown) => void;
|
|
60
|
+
}
|
|
61
|
+
type WebSocketBrowserRPC = BirpcReturn<WebSocketBrowserEvents, WebSocketBrowserHandlers>;
|
|
62
|
+
interface SourceMap {
|
|
63
|
+
file: string;
|
|
64
|
+
mappings: string;
|
|
65
|
+
names: string[];
|
|
66
|
+
sources: string[];
|
|
67
|
+
sourcesContent?: string[];
|
|
68
|
+
version: number;
|
|
69
|
+
toString: () => string;
|
|
70
|
+
toUrl: () => string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare class BrowserServerCDPHandler {
|
|
74
|
+
private session;
|
|
75
|
+
private tester;
|
|
76
|
+
private listenerIds;
|
|
77
|
+
private listeners;
|
|
78
|
+
constructor(session: CDPSession, tester: WebSocketBrowserRPC);
|
|
79
|
+
send(method: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
80
|
+
on(event: string, id: string, once?: boolean): void;
|
|
81
|
+
off(event: string, id: string): void;
|
|
82
|
+
once(event: string, listener: string): void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare class BrowserServerState implements BrowserServerState$1 {
|
|
86
|
+
readonly orchestrators: Map<string, WebSocketBrowserRPC>;
|
|
87
|
+
readonly testers: Map<string, WebSocketBrowserRPC>;
|
|
88
|
+
readonly cdps: Map<string, BrowserServerCDPHandler>;
|
|
89
|
+
private contexts;
|
|
90
|
+
getContext(contextId: string): BrowserServerStateContext | undefined;
|
|
91
|
+
createAsyncContext(method: 'run' | 'collect', contextId: string, files: string[]): Promise<void>;
|
|
92
|
+
removeCDPHandler(sessionId: string): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare class BrowserServer implements BrowserServer$1 {
|
|
96
|
+
project: WorkspaceProject;
|
|
97
|
+
base: string;
|
|
98
|
+
faviconUrl: string;
|
|
99
|
+
prefixTesterUrl: string;
|
|
100
|
+
orchestratorScripts: string | undefined;
|
|
101
|
+
testerScripts: string | undefined;
|
|
102
|
+
manifest: Promise<Vite.Manifest> | Vite.Manifest;
|
|
103
|
+
testerHtml: Promise<string> | string;
|
|
104
|
+
orchestratorHtml: Promise<string> | string;
|
|
105
|
+
injectorJs: Promise<string> | string;
|
|
106
|
+
stateJs: Promise<string> | string;
|
|
107
|
+
state: BrowserServerState;
|
|
108
|
+
provider: BrowserProvider;
|
|
109
|
+
vite: Vite.ViteDevServer;
|
|
110
|
+
private stackTraceOptions;
|
|
111
|
+
constructor(project: WorkspaceProject, base: string);
|
|
112
|
+
setServer(server: Vite.ViteDevServer): void;
|
|
113
|
+
getSerializableConfig(): ResolvedConfig;
|
|
114
|
+
resolveTesterUrl(pathname: string): {
|
|
115
|
+
contextId: string;
|
|
116
|
+
testFile: string;
|
|
117
|
+
};
|
|
118
|
+
formatScripts(scripts: BrowserScript[] | undefined): Promise<string>;
|
|
119
|
+
initBrowserProvider(): Promise<void>;
|
|
120
|
+
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
121
|
+
parseStacktrace(trace: string, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
122
|
+
private cdpSessions;
|
|
123
|
+
ensureCDPHandler(contextId: string, sessionId: string): Promise<BrowserServerCDPHandler>;
|
|
124
|
+
close(): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare function createBrowserPool(ctx: Vitest): ProcessPool;
|
|
128
|
+
|
|
129
|
+
declare function createBrowserServer(project: WorkspaceProject, configFile: string | undefined, prePlugins?: Plugin[], postPlugins?: Plugin[]): Promise<BrowserServer>;
|
|
130
|
+
|
|
131
|
+
export { BrowserServer, createBrowserPool, createBrowserServer };
|