Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: resolve filename in the resolution hook (#18221)

Pavel Feldmanfb643940e51d
diff --git a/packages/playwright-test/src/transform.ts b/packages/playwright-test/src/transform.ts
index 3e19ad29d1..aff93471fb 100644
--- a/packages/playwright-test/src/transform.ts
+++ b/packages/playwright-test/src/transform.ts
@@ -98,7 +98,7 @@ const scriptPreprocessor = process.env.PW_TEST_SOURCE_TRANSFORM ?
const builtins = new Set(Module.builtinModules);
export function resolveHook(filename: string, specifier: string): string | undefined {
- if (builtins.has(specifier))
+ if (specifier.startsWith('node:') || builtins.has(specifier))
return;
if (belongsToNodeModules(filename))
return;
@@ -154,7 +154,7 @@ export function resolveHook(filename: string, specifier: string): string | undef
for (const ext of ['', '.js', '.ts', '.mjs', '.cjs', '.jsx', '.tsx', '.cjs', '.mts', '.cts']) {
if (fs.existsSync(candidate + ext)) {
longestPrefixLength = keyPrefix.length;
- pathMatchedByLongestPrefix = candidate;
+ pathMatchedByLongestPrefix = candidate + ext;
}
}
}