Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: remove esm error interception, it only confuses users (#14829)
Pavel Feldman88664c39c9ee
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.tsindex 766217f422..5ae753b98b 100644--- a/packages/playwright-test/src/loader.ts+++ b/packages/playwright-test/src/loader.ts@@ -275,21 +275,6 @@ export class Loader {if (isModule)return await esmImport();return require(file);- } catch (error) {- if (error.code === 'ERR_MODULE_NOT_FOUND' && error.message.includes('Did you mean to import')) {- const didYouMean = /Did you mean to import (.*)\?/.exec(error.message)?.[1];- if (didYouMean?.endsWith('.ts'))- throw errorWithFile(file, 'Cannot import a typescript file from an esmodule.');- }- if (error.code === 'ERR_UNKNOWN_FILE_EXTENSION' && error.message.includes('.ts')) {- throw errorWithFile(file, `Cannot import a typescript file from an esmodule.\n${'='.repeat(80)}\nMake sure that:- - you are using Node.js 16+,- - your package.json contains "type": "module",- - you are using TypeScript for playwright.config.ts.-${'='.repeat(80)}\n`);- }-- throw error;} finally {revertBabelRequire();}diff --git a/tests/playwright-test/loader.spec.ts b/tests/playwright-test/loader.spec.tsindex 5245e642ac..51aa80b101 100644--- a/tests/playwright-test/loader.spec.ts+++ b/tests/playwright-test/loader.spec.ts@@ -238,7 +238,7 @@ test('should fail to load ts from esm when package.json has type module', async});expect(result.exitCode).toBe(1);- expect(result.output).toContain('Cannot import a typescript file from an esmodule');+ expect(result.output).toContain('Unknown file extension ".ts"');});test('should filter stack trace for simple expect', async ({ runInlineTest }) => {