@vitest/browser 2.0.0-beta.5 → 2.0.0-beta.6
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 +1 -1
- package/dist/client/.vite/manifest.json +1 -1
- package/dist/client/__vitest__/assets/{index-B74JATHR.css → index-DrQA2UkS.css} +1 -1
- package/dist/client/__vitest__/assets/index-T2_JR9hd.js +51 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/{orchestrator-CEB54dI4.js → orchestrator-D24IzA4b.js} +20 -32
- package/dist/client/orchestrator.html +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -7
- package/dist/client/__vitest__/assets/index-BoV0brgU.js +0 -51
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
})()
|
|
18
18
|
</script>
|
|
19
19
|
<!-- !LOAD_METADATA! -->
|
|
20
|
-
<script type="module" crossorigin src="./assets/index-
|
|
21
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
20
|
+
<script type="module" crossorigin src="./assets/index-T2_JR9hd.js"></script>
|
|
21
|
+
<link rel="stylesheet" crossorigin href="./assets/index-DrQA2UkS.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body>
|
|
24
24
|
<div id="app"></div>
|
package/dist/client/__vitest_browser__/{orchestrator-CEB54dI4.js → orchestrator-D24IzA4b.js}
RENAMED
|
@@ -38,11 +38,10 @@ function createIframe(container, file) {
|
|
|
38
38
|
iframe.setAttribute("loading", "eager");
|
|
39
39
|
iframe.setAttribute("src", `${url.pathname}__vitest_test__/__test__/${encodeURIComponent(file)}`);
|
|
40
40
|
iframe.setAttribute("data-vitest", "true");
|
|
41
|
-
const config = getConfig().browser;
|
|
42
|
-
iframe.style.width = `${config.viewport.width}px`;
|
|
43
|
-
iframe.style.height = `${config.viewport.height}px`;
|
|
44
41
|
iframe.style.display = "block";
|
|
45
42
|
iframe.style.border = "none";
|
|
43
|
+
iframe.style.zIndex = "1";
|
|
44
|
+
iframe.style.position = "relative";
|
|
46
45
|
iframe.setAttribute("allowfullscreen", "true");
|
|
47
46
|
iframe.setAttribute("allow", "clipboard-write;");
|
|
48
47
|
iframes.set(file, iframe);
|
|
@@ -70,10 +69,6 @@ async function getContainer(config) {
|
|
|
70
69
|
client.ws.addEventListener("open", async () => {
|
|
71
70
|
const testFiles = getBrowserState().files;
|
|
72
71
|
debug("test files", testFiles.join(", "));
|
|
73
|
-
if (!testFiles.length) {
|
|
74
|
-
await done();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
72
|
const runningFiles = new Set(testFiles);
|
|
78
73
|
channel.addEventListener("message", async (e) => {
|
|
79
74
|
var _a;
|
|
@@ -81,8 +76,6 @@ client.ws.addEventListener("open", async () => {
|
|
|
81
76
|
switch (e.data.type) {
|
|
82
77
|
case "viewport": {
|
|
83
78
|
const { width, height, id } = e.data;
|
|
84
|
-
const widthStr = typeof width === "number" ? `${width}px` : width;
|
|
85
|
-
const heightStr = typeof height === "number" ? `${height}px` : height;
|
|
86
79
|
const iframe = iframes.get(id);
|
|
87
80
|
if (!iframe) {
|
|
88
81
|
const error = new Error(`Cannot find iframe with id ${id}`);
|
|
@@ -93,13 +86,7 @@ client.ws.addEventListener("open", async () => {
|
|
|
93
86
|
}, "Teardown Error");
|
|
94
87
|
return;
|
|
95
88
|
}
|
|
96
|
-
iframe
|
|
97
|
-
iframe.style.height = heightStr;
|
|
98
|
-
const ui = getUiAPI();
|
|
99
|
-
if (ui) {
|
|
100
|
-
await new Promise((r) => requestAnimationFrame(r));
|
|
101
|
-
ui.recalculateDetailPanels();
|
|
102
|
-
}
|
|
89
|
+
await setIframeViewport(iframe, width, height);
|
|
103
90
|
channel.postMessage({ type: "viewport:done", id });
|
|
104
91
|
break;
|
|
105
92
|
}
|
|
@@ -110,7 +97,7 @@ client.ws.addEventListener("open", async () => {
|
|
|
110
97
|
const ui = getUiAPI();
|
|
111
98
|
if (ui && filenames.length > 1) {
|
|
112
99
|
const id = generateFileId(filenames[filenames.length - 1]);
|
|
113
|
-
ui.
|
|
100
|
+
ui.setCurrentFileId(id);
|
|
114
101
|
}
|
|
115
102
|
await done();
|
|
116
103
|
} else {
|
|
@@ -141,7 +128,8 @@ client.ws.addEventListener("open", async () => {
|
|
|
141
128
|
}
|
|
142
129
|
}
|
|
143
130
|
});
|
|
144
|
-
|
|
131
|
+
if (testFiles.length)
|
|
132
|
+
await createTesters(testFiles);
|
|
145
133
|
});
|
|
146
134
|
async function createTesters(testFiles) {
|
|
147
135
|
const config = getConfig();
|
|
@@ -150,29 +138,20 @@ async function createTesters(testFiles) {
|
|
|
150
138
|
container.className = "scrolls";
|
|
151
139
|
container.textContent = "";
|
|
152
140
|
}
|
|
141
|
+
const { width, height } = config.browser.viewport;
|
|
153
142
|
if (config.isolate === false) {
|
|
154
|
-
createIframe(
|
|
143
|
+
const iframe = createIframe(
|
|
155
144
|
container,
|
|
156
145
|
ID_ALL
|
|
157
146
|
);
|
|
158
|
-
|
|
159
|
-
if (ui) {
|
|
160
|
-
await new Promise((r) => requestAnimationFrame(r));
|
|
161
|
-
ui.recalculateDetailPanels();
|
|
162
|
-
}
|
|
147
|
+
await setIframeViewport(iframe, width, height);
|
|
163
148
|
} else {
|
|
164
149
|
for (const file of testFiles) {
|
|
165
|
-
const
|
|
166
|
-
createIframe(
|
|
150
|
+
const iframe = createIframe(
|
|
167
151
|
container,
|
|
168
152
|
file
|
|
169
153
|
);
|
|
170
|
-
|
|
171
|
-
const id = generateFileId(file);
|
|
172
|
-
ui.setCurrentById(id);
|
|
173
|
-
await new Promise((r) => requestAnimationFrame(r));
|
|
174
|
-
ui.recalculateDetailPanels();
|
|
175
|
-
}
|
|
154
|
+
await setIframeViewport(iframe, width, height);
|
|
176
155
|
await new Promise((resolve) => {
|
|
177
156
|
channel.addEventListener("message", function handler(e) {
|
|
178
157
|
if (e.data.type === "done" || e.data.type === "error") {
|
|
@@ -190,3 +169,12 @@ function generateFileId(file) {
|
|
|
190
169
|
const path = relative(config.root, file);
|
|
191
170
|
return generateHash(`${path}${project}`);
|
|
192
171
|
}
|
|
172
|
+
async function setIframeViewport(iframe, width, height) {
|
|
173
|
+
const ui = getUiAPI();
|
|
174
|
+
if (ui) {
|
|
175
|
+
await ui.setIframeViewport(width, height);
|
|
176
|
+
} else {
|
|
177
|
+
iframe.style.width = `${width}px`;
|
|
178
|
+
iframe.style.height = `${height}px`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</style>
|
|
26
26
|
<script>{__VITEST_INJECTOR__}</script>
|
|
27
27
|
{__VITEST_SCRIPTS__}
|
|
28
|
-
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-
|
|
28
|
+
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-D24IzA4b.js"></script>
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/rpc-DBukiZYG.js">
|
|
30
30
|
</head>
|
|
31
31
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -308,7 +308,7 @@ export const page = {
|
|
|
308
308
|
viewport(width, height) {
|
|
309
309
|
const id = __vitest_browser_runner__.iframeId
|
|
310
310
|
channel.postMessage({ type: 'viewport', width, height, id })
|
|
311
|
-
return new Promise((resolve) => {
|
|
311
|
+
return new Promise((resolve, reject) => {
|
|
312
312
|
channel.addEventListener('message', function handler(e) {
|
|
313
313
|
if (e.data.type === 'viewport:done' && e.data.id === id) {
|
|
314
314
|
channel.removeEventListener('message', handler)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.6",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"playwright": "*",
|
|
49
49
|
"webdriverio": "*",
|
|
50
|
-
"vitest": "2.0.0-beta.
|
|
50
|
+
"vitest": "2.0.0-beta.6"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"playwright": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"magic-string": "^0.30.10",
|
|
65
65
|
"sirv": "^2.0.4",
|
|
66
|
-
"@vitest/utils": "2.0.0-beta.
|
|
66
|
+
"@vitest/utils": "2.0.0-beta.6"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/ws": "^8.5.10",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"playwright-core": "^1.44.0",
|
|
76
76
|
"safaridriver": "^0.1.2",
|
|
77
77
|
"webdriverio": "^8.36.1",
|
|
78
|
-
"@vitest/
|
|
79
|
-
"@vitest/
|
|
80
|
-
"@vitest/ws-client": "2.0.0-beta.
|
|
81
|
-
"vitest": "2.0.0-beta.
|
|
78
|
+
"@vitest/ui": "2.0.0-beta.6",
|
|
79
|
+
"@vitest/runner": "2.0.0-beta.6",
|
|
80
|
+
"@vitest/ws-client": "2.0.0-beta.6",
|
|
81
|
+
"vitest": "2.0.0-beta.6"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "rimraf dist && pnpm build:node && pnpm build:client",
|