@vitest/browser 2.1.3 → 2.1.5
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/README.md +7 -21
- package/context.d.ts +6 -0
- package/dist/client/.vite/manifest.json +7 -7
- package/dist/client/__vitest__/assets/index-CGSAdLIf.css +1 -0
- package/dist/client/__vitest__/assets/index-DWjHzG4O.js +52 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/orchestrator-DnP17K36.js +238 -0
- package/dist/client/__vitest_browser__/{tester-DZCtFstH.js → tester-BaiNqOPw.js} +7749 -6109
- package/dist/client/__vitest_browser__/utils-Owv5OOOf.js +195 -0
- package/dist/client/error-catcher.js +3 -1
- package/dist/client/esm-client-injector.js +50 -48
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +3 -19
- package/dist/client.js +28 -5
- package/dist/context.js +96 -47
- package/dist/{index-Cgg35wOd.js → index-CKtADM3n.js} +35 -3
- package/dist/index.d.ts +10 -6
- package/dist/index.js +2016 -1825
- package/dist/locators/index.js +1 -1
- package/dist/locators/playwright.js +1 -1
- package/dist/locators/preview.js +11 -11
- package/dist/locators/webdriverio.js +1 -1
- package/dist/providers.js +8 -7
- package/dist/state.js +1 -1
- package/dist/utils.js +1 -1
- package/package.json +18 -18
- package/dist/client/__vitest__/assets/index-CADIw8eX.js +0 -52
- package/dist/client/__vitest__/assets/index-D5rK8X7L.css +0 -1
- package/dist/client/__vitest_browser__/orchestrator-BCPid0xo.js +0 -1099
- package/dist/client/__vitest_browser__/preload-helper-D-WYp1PK.js +0 -317
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { server, page } from '@vitest/browser/context';
|
|
2
2
|
import { I as Ivya, a as getByRoleSelector, c as getByAltTextSelector, g as getByLabelSelector, d as getByPlaceholderSelector, b as getByTestIdSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from './public-utils-D6S2-5kI.js';
|
|
3
3
|
|
|
4
|
+
function ensureAwaited(promise) {
|
|
5
|
+
const test = (/* @__PURE__ */ getWorkerState()).current;
|
|
6
|
+
if (!test || test.type !== "test") {
|
|
7
|
+
return promise();
|
|
8
|
+
}
|
|
9
|
+
let awaited = false;
|
|
10
|
+
const sourceError = new Error("STACK_TRACE_ERROR");
|
|
11
|
+
test.onFinished ??= [];
|
|
12
|
+
test.onFinished.push(() => {
|
|
13
|
+
if (!awaited) {
|
|
14
|
+
const error = new Error(
|
|
15
|
+
`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`
|
|
16
|
+
);
|
|
17
|
+
error.stack = sourceError.stack?.replace(sourceError.message, error.message);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
let promiseResult;
|
|
22
|
+
return {
|
|
23
|
+
then(onFulfilled, onRejected) {
|
|
24
|
+
awaited = true;
|
|
25
|
+
return (promiseResult ||= promise()).then(onFulfilled, onRejected);
|
|
26
|
+
},
|
|
27
|
+
catch(onRejected) {
|
|
28
|
+
return (promiseResult ||= promise()).catch(onRejected);
|
|
29
|
+
},
|
|
30
|
+
finally(onFinally) {
|
|
31
|
+
return (promiseResult ||= promise()).finally(onFinally);
|
|
32
|
+
},
|
|
33
|
+
[Symbol.toStringTag]: "Promise"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
4
36
|
// @__NO_SIDE_EFFECTS__
|
|
5
37
|
function getBrowserState() {
|
|
6
38
|
return window.__vitest_browser_runner__;
|
|
@@ -214,13 +246,13 @@ class Locator {
|
|
|
214
246
|
}
|
|
215
247
|
triggerCommand(command, ...args) {
|
|
216
248
|
const filepath = this.worker.filepath || this.worker.current?.file?.filepath || void 0;
|
|
217
|
-
return this.rpc.triggerCommand(
|
|
249
|
+
return ensureAwaited(() => this.rpc.triggerCommand(
|
|
218
250
|
this.state.contextId,
|
|
219
251
|
command,
|
|
220
252
|
filepath,
|
|
221
253
|
args
|
|
222
|
-
);
|
|
254
|
+
));
|
|
223
255
|
}
|
|
224
256
|
}
|
|
225
257
|
|
|
226
|
-
export { Locator as L, convertElementToCssSelector as c, selectorEngine as s };
|
|
258
|
+
export { Locator as L, convertElementToCssSelector as c, ensureAwaited as e, selectorEngine as s };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, WorkspaceProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node';
|
|
2
1
|
import { Plugin } from 'vitest/config';
|
|
2
|
+
import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, WorkspaceProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node';
|
|
3
3
|
import * as vitest from 'vitest';
|
|
4
|
-
import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig } from 'vitest';
|
|
5
|
-
import {
|
|
4
|
+
import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff } from 'vitest';
|
|
5
|
+
import { HtmlTagDescriptor } from 'vite';
|
|
6
6
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
7
7
|
import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
|
|
8
8
|
|
|
@@ -19,6 +19,7 @@ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
|
19
19
|
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
20
20
|
} & {
|
|
21
21
|
$functions: LocalFunctions;
|
|
22
|
+
$close: () => void;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
interface WebSocketBrowserHandlers {
|
|
@@ -94,9 +95,10 @@ declare class BrowserServer implements BrowserServer$1 {
|
|
|
94
95
|
faviconUrl: string;
|
|
95
96
|
prefixTesterUrl: string;
|
|
96
97
|
orchestratorScripts: string | undefined;
|
|
97
|
-
testerScripts:
|
|
98
|
+
testerScripts: HtmlTagDescriptor[] | undefined;
|
|
98
99
|
manifest: Promise<Vite.Manifest> | Vite.Manifest;
|
|
99
100
|
testerHtml: Promise<string> | string;
|
|
101
|
+
testerFilepath: string;
|
|
100
102
|
orchestratorHtml: Promise<string> | string;
|
|
101
103
|
injectorJs: Promise<string> | string;
|
|
102
104
|
errorCatcherUrl: string;
|
|
@@ -113,7 +115,7 @@ declare class BrowserServer implements BrowserServer$1 {
|
|
|
113
115
|
contextId: string;
|
|
114
116
|
testFile: string;
|
|
115
117
|
};
|
|
116
|
-
formatScripts(scripts: BrowserScript[] | undefined): Promise<
|
|
118
|
+
formatScripts(scripts: BrowserScript[] | undefined): Promise<HtmlTagDescriptor[]>;
|
|
117
119
|
initBrowserProvider(): Promise<void>;
|
|
118
120
|
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
119
121
|
parseStacktrace(trace: string, options?: StackTraceParserOptions): vitest.ParsedStack[];
|
|
@@ -122,8 +124,10 @@ declare class BrowserServer implements BrowserServer$1 {
|
|
|
122
124
|
close(): Promise<void>;
|
|
123
125
|
}
|
|
124
126
|
|
|
127
|
+
declare const distRoot: string;
|
|
128
|
+
|
|
125
129
|
declare function createBrowserPool(ctx: Vitest): ProcessPool;
|
|
126
130
|
|
|
127
131
|
declare function createBrowserServer(project: WorkspaceProject, configFile: string | undefined, prePlugins?: Plugin[], postPlugins?: Plugin[]): Promise<BrowserServer>;
|
|
128
132
|
|
|
129
|
-
export { BrowserServer, createBrowserPool, createBrowserServer };
|
|
133
|
+
export { BrowserServer, createBrowserPool, createBrowserServer, distRoot };
|