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
fix(test-runner): ESM compatibly on Windows (#12615)
Max Schmitt3f468abedd80
diff --git a/.github/workflows/tests_primary.yml b/.github/workflows/tests_primary.ymlindex 1b39ec9bf1..b18b7716bd 100644--- a/.github/workflows/tests_primary.yml+++ b/.github/workflows/tests_primary.yml@@ -56,9 +56,6 @@ jobs:matrix:os: [ubuntu-latest, windows-latest, macos-latest]node-version: [12]- include:- - os: ubuntu-latest- node-version: 16runs-on: ${{ matrix.os }}steps:- uses: actions/checkout@v2@@ -78,6 +75,26 @@ jobs:- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.jsonif: always()+ test_test_runner_esm:+ name: Test Runner ESM+ strategy:+ fail-fast: false+ matrix:+ os: [ubuntu-latest, windows-latest, macos-latest]+ runs-on: ${{ matrix.os }}+ steps:+ - uses: actions/checkout@v2+ - uses: actions/setup-node@v2+ with:+ node-version: 16+ - run: npm i -g [email protected]+ - run: npm ci+ env:+ DEBUG: pw:install+ - run: npm run build+ - run: npx playwright install --with-deps+ - run: npm run ttest -- --grep=@esm+test_html_report:name: HTML Reportruns-on: ubuntu-latestdiff --git a/packages/playwright-test/src/cli.ts b/packages/playwright-test/src/cli.tsindex 94317ba54e..cc82e135e9 100644--- a/packages/playwright-test/src/cli.ts+++ b/packages/playwright-test/src/cli.ts@@ -18,6 +18,7 @@import { Command } from 'commander';import fs from 'fs';+import url from 'url';import path from 'path';import type { Config } from './types';import { Runner, builtInReporters, BuiltInReporter, kDefaultConfigFiles } from './runner';@@ -245,7 +246,7 @@ function restartWithExperimentalTsEsm(configFile: string | null): boolean {return false;if (!fileIsModule(configFile))return false;- const NODE_OPTIONS = (process.env.NODE_OPTIONS || '') + ` --experimental-loader=${require.resolve('@playwright/test/lib/experimentalLoader')}`;+ const NODE_OPTIONS = (process.env.NODE_OPTIONS || '') + ` --experimental-loader=${url.pathToFileURL(require.resolve('@playwright/test/lib/experimentalLoader')).toString()}`;const innerProcess = require('child_process').fork(require.resolve('playwright-core/cli'), process.argv.slice(2), {env: {...process.env,diff --git a/tests/playwright-test/loader.spec.ts b/tests/playwright-test/loader.spec.tsindex 2280c602e7..a2ffe5233b 100644--- a/tests/playwright-test/loader.spec.ts+++ b/tests/playwright-test/loader.spec.ts@@ -241,7 +241,7 @@ test('should fail to load ts from esm when package.json has type module', asyncexpect(result.output).toContain('Cannot import a typescript file from an esmodule');});-test('should import esm from ts when package.json has type module in experimental mode', async ({ runInlineTest }) => {+test('should import esm from ts when package.json has type module in experimental mode @esm', async ({ runInlineTest }) => {// We only support experimental esm mode on Node 16+test.skip(parseInt(process.version.slice(1), 10) < 16);const result = await runInlineTest({@@ -267,7 +267,7 @@ test('should import esm from ts when package.json has type module in experimentaexpect(result.exitCode).toBe(0);});-test('should propagate subprocess exit code in experimental mode', async ({ runInlineTest }) => {+test('should propagate subprocess exit code in experimental mode @esm', async ({ runInlineTest }) => {// We only support experimental esm mode on Node 16+test.skip(parseInt(process.version.slice(1), 10) < 16);const result = await runInlineTest({diff --git a/tests/playwright-test/resolver.spec.ts b/tests/playwright-test/resolver.spec.tsindex 2fcf79a1ac..61a66a9d3e 100644--- a/tests/playwright-test/resolver.spec.ts+++ b/tests/playwright-test/resolver.spec.ts@@ -164,7 +164,7 @@ test('should respect baseurl w/o paths', async ({ runInlineTest }) => {expect(result.output).not.toContain(`Could not`);});-test('should respect path resolver in experimental mode', async ({ runInlineTest }) => {+test('should respect path resolver in experimental mode @esm', async ({ runInlineTest }) => {// We only support experimental esm mode on Node 16+test.skip(parseInt(process.version.slice(1), 10) < 16);const result = await runInlineTest({