From c4b003a29a2a95e109ab13a068559c72464c0afc Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 3 Jun 2022 15:28:53 -0700 Subject: [PATCH] chore: don't mask ESM error (#14628) --- packages/playwright-test/src/loader.ts | 3 --- tests/playwright-test/loader.spec.ts | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) 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 }) => {