Version
1.61.0
Steps to reproduce
Repro repo: https://github.com/likitakotian/Playwright-Testing
Branch: repro/playwright-161-conditions-bug
Folder: repro/
Failing CI (Node 22.15.0): https://github.com/likitakotian/Playwright-Testing/actions/runs/27570859984
Steps:
- git clone https://github.com/likitakotian/Playwright-Testing.git
- git checkout repro/playwright-161-conditions-bug
- cd repro
- Use Node 22.15.x (required — does NOT reproduce on Node 22.17+)
- npm ci
- npx playwright test
Or open the failing GitHub Actions run above.
Expected behavior
Tests load and run.
Actual behavior
Suite fails during module loading:
TypeError: context.conditions?.includes is not a function
Playwright 1.61 sync loader (esmLoaderSync in playwright/lib/common/index.js):
specifier = context.conditions?.includes("import") ? pathToFileURL(resolved).toString() : resolved;
Optional chaining means context.conditions exists but is not an Array.
Node 22.15–22.16 may pass context.conditions as a Set for require()-initiated
resolution in registerHooks: nodejs/node#59003
(fixed in Node 22.17: nodejs/node#59011)
Related: #41121 / #41138 (same line, Windows file:// case).
Suggested fix:
const isImport = context.conditions?.has?.('import') ?? context.conditions?.includes?.('import');
Additional context
No response
Environment
OS: Ubuntu latest (GitHub Actions)
Node: 22.15.0
@playwright/test: 1.61.0
Version
1.61.0
Steps to reproduce
Repro repo: https://github.com/likitakotian/Playwright-Testing
Branch: repro/playwright-161-conditions-bug
Folder: repro/
Failing CI (Node 22.15.0): https://github.com/likitakotian/Playwright-Testing/actions/runs/27570859984
Steps:
Or open the failing GitHub Actions run above.
Expected behavior
Tests load and run.
Actual behavior
Suite fails during module loading:
TypeError: context.conditions?.includes is not a function
Playwright 1.61 sync loader (esmLoaderSync in playwright/lib/common/index.js):
specifier = context.conditions?.includes("import") ? pathToFileURL(resolved).toString() : resolved;
Optional chaining means context.conditions exists but is not an Array.
Node 22.15–22.16 may pass context.conditions as a Set for require()-initiated
resolution in registerHooks: nodejs/node#59003
(fixed in Node 22.17: nodejs/node#59011)
Related: #41121 / #41138 (same line, Windows file:// case).
Suggested fix:
const isImport = context.conditions?.has?.('import') ?? context.conditions?.includes?.('import');
Additional context
No response
Environment