From 687ae50313010b98fe15775b230dd032d52118cb Mon Sep 17 00:00:00 2001 From: DavertMik Date: Fri, 21 Aug 2026 03:35:02 +0300 Subject: [PATCH] Require playwright-core 1.62+, where asLocator now lives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Playwright 1.62 dropped lib/utils from playwright-core and moved the isomorphic helpers into lib/coreBundle, exported as ./lib/coreBundle with asLocator under the iso namespace. The recorder still required playwright-core/lib/utils, so it threw PLAYWRIGHT_INCOMPATIBLE and every renderCall test failed. package.json asked for playwright ^1.62 but never for playwright-core, so the copy at the root of the tree was whatever satisfied @axe-core/playwright's playwright-core >= 1.0.0 peer. A fresh install deduped it to 1.62.1 and CI went red, while a tree still holding an older copy resolved lib/utils and passed — which is why this never showed up locally. playwright-core ^1.62 is now a direct dependency, so the root copy is the one the recorder is written against, and getAsLocator reads iso.asLocator from lib/coreBundle and nothing else. Co-Authored-By: Claude Opus 5 (1M context) --- bun.lock | 5 ++--- package.json | 1 + src/playwright-recorder.ts | 17 ++++++----------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/bun.lock b/bun.lock index 7bb52d82..a062e6c1 100644 --- a/bun.lock +++ b/bun.lock @@ -53,6 +53,7 @@ "parse5": "^8.0.0", "pixelmatch": "^7.2.0", "playwright": "^1.62", + "playwright-core": "^1.62", "pngjs": "^7.0.0", "react": "^19.1.1", "sambanova-ai-provider": "^1.2.2", @@ -2155,7 +2156,7 @@ "playwright": ["playwright@1.62.1", "", { "dependencies": { "playwright-core": "1.62.1" }, "optionalDependencies": { "fsevents": "2.3.2" }, "bin": { "playwright": "cli.js" } }, "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg=="], - "playwright-core": ["playwright-core@1.54.1", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-Nbjs2zjj0htNhzgiy5wu+3w09YetDx5pkrpI/kZotDlDUaYk0HVA5xrBVPdow4SAUIlhgKcJeJg4GRKW6xHusA=="], + "playwright-core": ["playwright-core@1.62.1", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw=="], "pngjs": ["pngjs@7.0.0", "", {}, "sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow=="], @@ -3209,8 +3210,6 @@ "path-scurry/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="], - "playwright/playwright-core": ["playwright-core@1.62.1", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw=="], - "pretty-format/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="], "pretty-format/ansi-styles": ["ansi-styles@5.2.0", "", {}, "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA=="], diff --git a/package.json b/package.json index 76698b13..f8fb6d61 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,7 @@ "parse5": "^8.0.0", "pixelmatch": "^7.2.0", "playwright": "^1.62", + "playwright-core": "^1.62", "pngjs": "^7.0.0", "react": "^19.1.1", "sambanova-ai-provider": "^1.2.2", diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 71a18364..039c31f2 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -9,7 +9,7 @@ const RECORDABLE: Record> = { Page: new Set(['goBack', 'goForward', 'reload', 'keyboardPress', 'keyboardType', 'keyboardDown', 'keyboardUp', 'keyboardInsertText', 'mouseClick', 'mouseDblclick', 'mouseMove', 'mouseDown', 'mouseUp', 'mouseWheel']), }; -const PLAYWRIGHT_INCOMPATIBLE = "Playwright output is not compatible with this Playwright version (playwright-core/lib/utils does not expose asLocator). Use output.framework: 'codeceptjs' instead, or pin Playwright to a version shipping lib/utils/isomorphic/locatorGenerators.js."; +const PLAYWRIGHT_INCOMPATIBLE = "Playwright output requires playwright-core 1.62 or newer (lib/coreBundle does not expose iso.asLocator). Use output.framework: 'codeceptjs' instead."; let cachedAsLocator: ((lang: string, selector: string) => string) | null = null; let asLocatorLoadAttempted = false; @@ -20,16 +20,11 @@ function getAsLocator(): (lang: string, selector: string) => string { if (asLocatorLoadAttempted) throw new Error(PLAYWRIGHT_INCOMPATIBLE); asLocatorLoadAttempted = true; - try { - const mod = nodeRequire('playwright-core/lib/utils'); - if (typeof (mod as any)?.asLocator === 'function') { - cachedAsLocator = (mod as any).asLocator; - return cachedAsLocator!; - } - } catch { - // Module not exported or not found - } - throw new Error(PLAYWRIGHT_INCOMPATIBLE); + const asLocator = nodeRequire('playwright-core/lib/coreBundle')?.iso?.asLocator; + if (typeof asLocator !== 'function') throw new Error(PLAYWRIGHT_INCOMPATIBLE); + + cachedAsLocator = asLocator; + return cachedAsLocator; } export interface TraceCall {