Skip to content

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

chore: don't mask ESM error (#14628)

Pavel Feldmanc4b003a29a2a
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.ts
index 9ad9b10570..766217f422 100644
--- a/packages/playwright-test/src/loader.ts
+++ b/packages/playwright-test/src/loader.ts
@@ -289,9 +289,6 @@ export class Loader {
${'='.repeat(80)}\n`);
}
- if (error instanceof SyntaxError && error.message.includes('Cannot use import statement outside a module'))
- throw errorWithFile(file, 'JavaScript files must end with .mjs to use import.');
-
throw error;
} finally {
revertBabelRequire();
diff --git a/tests/playwright-test/loader.spec.ts b/tests/playwright-test/loader.spec.ts
index ceb63a97a3..5245e642ac 100644
--- a/tests/playwright-test/loader.spec.ts
+++ b/tests/playwright-test/loader.spec.ts
@@ -175,7 +175,7 @@ test('should throw a nice error if a js file uses import', async ({ runInlineTes
});
expect(exitCode).toBe(1);
expect(output).toContain('a.spec.js');
- expect(output).toContain('JavaScript files must end with .mjs to use import.');
+ expect(output).toContain('Cannot use import statement outside a module');
});
test('should load esm when package.json has type module', async ({ runInlineTest }) => {