@vitest/browser 2.1.0-beta.6 → 2.1.0-beta.7
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 +11 -0
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-CEU6kzsk.js +52 -0
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{orchestrator-CoMoQEYq.js → orchestrator-qtq9EW1J.js} +243 -91
- package/dist/client/__vitest_browser__/preload-helper-D-WYp1PK.js +317 -0
- package/dist/client/__vitest_browser__/{tester-C7y_vb57.js → tester-Bm6k0JOu.js} +585 -371
- package/dist/client/esm-client-injector.js +1 -0
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/context.js +3 -0
- package/dist/{index-DcU_z8HM.js → index-Cgg35wOd.js} +19 -0
- package/dist/index.d.ts +7 -13
- package/dist/index.js +287 -263
- package/dist/locators/index.d.ts +1 -0
- package/dist/locators/index.js +1 -1
- package/dist/locators/playwright.js +1 -1
- package/dist/locators/preview.js +4 -1
- package/dist/locators/webdriverio.js +1 -1
- package/dist/providers.js +1 -1
- package/dist/state.js +1 -1
- package/dist/{webdriver-BdVqnfdE.js → webdriver-Cv9wga63.js} +10 -1
- package/package.json +10 -7
- package/dist/client/__vitest__/assets/index-D7jfm8wn.js +0 -52
- package/dist/client/__vitest_browser__/preload-helper-YsBSwBkS.js +0 -310
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
{__VITEST_INJECTOR__}
|
|
27
27
|
{__VITEST_ERROR_CATCHER__}
|
|
28
28
|
{__VITEST_SCRIPTS__}
|
|
29
|
-
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-
|
|
30
|
-
<link rel="modulepreload" crossorigin href="/__vitest_browser__/preload-helper-
|
|
29
|
+
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-qtq9EW1J.js"></script>
|
|
30
|
+
<link rel="modulepreload" crossorigin href="/__vitest_browser__/preload-helper-D-WYp1PK.js">
|
|
31
31
|
</head>
|
|
32
32
|
<body>
|
|
33
33
|
<div id="vitest-tester"></div>
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
<script>{__VITEST_STATE__}</script>
|
|
21
21
|
{__VITEST_INTERNAL_SCRIPTS__}
|
|
22
22
|
{__VITEST_SCRIPTS__}
|
|
23
|
-
<script type="module" crossorigin src="/__vitest_browser__/tester-
|
|
24
|
-
<link rel="modulepreload" crossorigin href="/__vitest_browser__/preload-helper-
|
|
23
|
+
<script type="module" crossorigin src="/__vitest_browser__/tester-Bm6k0JOu.js"></script>
|
|
24
|
+
<link rel="modulepreload" crossorigin href="/__vitest_browser__/preload-helper-D-WYp1PK.js">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
{__VITEST_APPEND__}
|
package/dist/context.js
CHANGED
|
@@ -140,6 +140,9 @@ function createUserEvent() {
|
|
|
140
140
|
unhover(element, options = {}) {
|
|
141
141
|
return convertToLocator(element).unhover(options);
|
|
142
142
|
},
|
|
143
|
+
upload(element, files) {
|
|
144
|
+
return convertToLocator(element).upload(files);
|
|
145
|
+
},
|
|
143
146
|
// non userEvent events, but still useful
|
|
144
147
|
fill(element, text, options) {
|
|
145
148
|
return convertToLocator(element).fill(text, options);
|
|
@@ -121,6 +121,25 @@ class Locator {
|
|
|
121
121
|
fill(text, options) {
|
|
122
122
|
return this.triggerCommand("__vitest_fill", this.selector, text, options);
|
|
123
123
|
}
|
|
124
|
+
async upload(files) {
|
|
125
|
+
const filesPromise = (Array.isArray(files) ? files : [files]).map(async (file) => {
|
|
126
|
+
if (typeof file === "string") {
|
|
127
|
+
return file;
|
|
128
|
+
}
|
|
129
|
+
const bas64String = await new Promise((resolve, reject) => {
|
|
130
|
+
const reader = new FileReader();
|
|
131
|
+
reader.onload = () => resolve(reader.result);
|
|
132
|
+
reader.onerror = () => reject(new Error(`Failed to read file: ${file.name}`));
|
|
133
|
+
reader.readAsDataURL(file);
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
name: file.name,
|
|
137
|
+
mimeType: file.type,
|
|
138
|
+
base64: bas64String
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
return this.triggerCommand("__vitest_upload", this.selector, await Promise.all(filesPromise));
|
|
142
|
+
}
|
|
124
143
|
dropTo(target, options = {}) {
|
|
125
144
|
return this.triggerCommand(
|
|
126
145
|
"__vitest_dragAndDrop",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, WorkspaceProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node';
|
|
2
2
|
import { Plugin } from 'vitest/config';
|
|
3
3
|
import * as vitest from 'vitest';
|
|
4
|
-
import {
|
|
4
|
+
import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig } from 'vitest';
|
|
5
5
|
import { ErrorWithDiff } from '@vitest/utils';
|
|
6
6
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
7
|
+
import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
|
|
7
8
|
|
|
8
9
|
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
9
10
|
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
@@ -24,7 +25,7 @@ interface WebSocketBrowserHandlers {
|
|
|
24
25
|
resolveSnapshotPath: (testPath: string) => string;
|
|
25
26
|
resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
|
|
26
27
|
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
27
|
-
onCollected: (files?:
|
|
28
|
+
onCollected: (files?: RunnerTestFile[]) => Promise<void>;
|
|
28
29
|
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
29
30
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
30
31
|
onCancel: (reason: CancelReason) => void;
|
|
@@ -36,18 +37,11 @@ interface WebSocketBrowserHandlers {
|
|
|
36
37
|
finishBrowserTests: (contextId: string) => void;
|
|
37
38
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
38
39
|
debug: (...args: string[]) => void;
|
|
39
|
-
resolveId: (id: string, importer?: string) => Promise<
|
|
40
|
-
id: string;
|
|
41
|
-
url: string;
|
|
42
|
-
optimized: boolean;
|
|
43
|
-
} | null>;
|
|
40
|
+
resolveId: (id: string, importer?: string) => Promise<ServerIdResolution | null>;
|
|
44
41
|
triggerCommand: <T>(contextId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
|
|
45
|
-
resolveMock: (id: string, importer: string,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
resolvedId: string;
|
|
49
|
-
needsInterop?: boolean;
|
|
50
|
-
}>;
|
|
42
|
+
resolveMock: (id: string, importer: string, options: {
|
|
43
|
+
mock: 'spy' | 'factory' | 'auto';
|
|
44
|
+
}) => Promise<ServerMockResolution>;
|
|
51
45
|
invalidate: (ids: string[]) => void;
|
|
52
46
|
getBrowserFileSourceMap: (id: string) => SourceMap | null | {
|
|
53
47
|
mappings: '';
|