@vitest/browser-playwright 5.1.0-beta.1 → 5.1.0
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/dist/index.js +12 -7
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -169,6 +169,14 @@ const basename = function(p, extension) {
|
|
|
169
169
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
170
170
|
};
|
|
171
171
|
|
|
172
|
+
async function focusIframe(context) {
|
|
173
|
+
const frame = await context.frame();
|
|
174
|
+
await frame.evaluate(() => {
|
|
175
|
+
if (!document.activeElement || document.activeElement.ownerDocument !== document || document.activeElement === document.body) {
|
|
176
|
+
window.focus();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
172
180
|
// strip iframe locator part from the trace description e.g.
|
|
173
181
|
// - locator('[data-vitest="true"]').contentFrame().getByRole('button')
|
|
174
182
|
// ⇓
|
|
@@ -184,12 +192,15 @@ const clear = async (context, selector) => {
|
|
|
184
192
|
};
|
|
185
193
|
|
|
186
194
|
const click = async (context, selector, options = {}) => {
|
|
195
|
+
await focusIframe(context);
|
|
187
196
|
await getDescribedLocator(context, selector).click(options);
|
|
188
197
|
};
|
|
189
198
|
const dblClick = async (context, selector, options = {}) => {
|
|
199
|
+
await focusIframe(context);
|
|
190
200
|
await getDescribedLocator(context, selector).dblclick(options);
|
|
191
201
|
};
|
|
192
202
|
const tripleClick = async (context, selector, options = {}) => {
|
|
203
|
+
await focusIframe(context);
|
|
193
204
|
await getDescribedLocator(context, selector).click({
|
|
194
205
|
...options,
|
|
195
206
|
clickCount: 3
|
|
@@ -211,8 +222,7 @@ const hover = async (context, selector, options = {}) => {
|
|
|
211
222
|
};
|
|
212
223
|
|
|
213
224
|
const keyboard = async (context, text, state) => {
|
|
214
|
-
|
|
215
|
-
await frame.evaluate(focusIframe);
|
|
225
|
+
await focusIframe(context);
|
|
216
226
|
const pressed = new Set(state.unreleased);
|
|
217
227
|
await keyboardImplementation(pressed, context.provider, context.sessionId, text, async () => {
|
|
218
228
|
const frame = await context.frame();
|
|
@@ -485,11 +495,6 @@ async function keyboardImplementation(pressed, provider, sessionId, text, select
|
|
|
485
495
|
}
|
|
486
496
|
return { pressed };
|
|
487
497
|
}
|
|
488
|
-
function focusIframe() {
|
|
489
|
-
if (!document.activeElement || document.activeElement.ownerDocument !== document || document.activeElement === document.body) {
|
|
490
|
-
window.focus();
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
498
|
function selectAll() {
|
|
494
499
|
const element = document.activeElement;
|
|
495
500
|
if (element && typeof element.select === "function") {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser-playwright",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.1.0
|
|
4
|
+
"version": "5.1.0",
|
|
5
5
|
"description": "Browser running for Vitest using playwright",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"playwright": "*",
|
|
46
|
-
"vitest": "5.1.0
|
|
46
|
+
"vitest": "5.1.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"playwright": {
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vitest/browser": "5.1.0
|
|
55
|
-
"@vitest/mocker": "5.1.0
|
|
54
|
+
"@vitest/browser": "5.1.0",
|
|
55
|
+
"@vitest/mocker": "5.1.0",
|
|
56
56
|
"tinyrainbow": "^3.2.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"pathe": "^2.0.3",
|
|
60
60
|
"playwright": "^1.64.1",
|
|
61
|
-
"vite": "8.
|
|
62
|
-
"vitest": "5.1.0
|
|
61
|
+
"vite": "8.3.5",
|
|
62
|
+
"vitest": "5.1.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "premove dist && pnpm rollup -c",
|