I'm just getting started with Playwright so I don't know if there is something I'm missing. I do not have any other testing framework wired up to it. I'm using @playwright/test v1.14.1
.
This test:
import { test, expect } from "@playwright/test";
test("focus sets tab indexes appropriately", async ({ page }) => {
await page.goto("http://localhost:3000/test");
const inputs = page.locator("input");
await expect(inputs).toHaveCount(5);
await inputs.evaluateAll(async (nodes) => {
console.log(nodes);
for (const node of nodes) {
console.log(node);
await expect(node.tabIndex).toBe(0);
}
});
});
is producing the following error:
locator.evaluateAll: Evaluation failed: ReferenceError: _test is not defined
at eval (eval at evaluate (:3:1339), <anonymous>:6:7)
at t.default.evaluate (<anonymous>:3:1362)
at t.default.<anonymous> (<anonymous>:1:44)
5 | const inputs = page.locator("input");
6 | await expect(inputs).toHaveCount(5);
> 7 | await inputs.evaluateAll(async (nodes) => {
| ^
8 | console.log(nodes);
9 | for (const node of nodes) {
10 | console.log(node);
If I remove the call to expect
, the test passes but the console.log
still will not fire off.
input.evaluateAll
gets executed inside the browser which is a different execution context in which expect
is not available (Node.js vs. e.g. Chromium).
See here: https://playwright.dev/docs/evaluating