From 9d3e76bf627b16bae392b2bad691b882cc24548f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 19 Oct 2023 08:37:37 +0200 Subject: [PATCH] Scripts: fix default Playwright config (#55453) --- packages/scripts/config/playwright.config.js | 5 +---- packages/scripts/config/playwright/global-setup.js | 4 ++-- packages/scripts/scripts/test-playwright.js | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/scripts/config/playwright.config.js b/packages/scripts/config/playwright.config.js index 6f380017ccdc4f..03ccbb848554b2 100644 --- a/packages/scripts/config/playwright.config.js +++ b/packages/scripts/config/playwright.config.js @@ -2,7 +2,6 @@ * External dependencies */ const path = require( 'path' ); -const { fileURLToPath } = require( 'url' ); const { defineConfig, devices } = require( '@playwright/test' ); process.env.WP_ARTIFACTS_PATH ??= path.join( process.cwd(), 'artifacts' ); @@ -24,9 +23,7 @@ const config = defineConfig( { outputDir: path.join( process.env.WP_ARTIFACTS_PATH, 'test-results' ), snapshotPathTemplate: '{testDir}/{testFileDir}/__snapshots__/{arg}-{projectName}{ext}', - globalSetup: fileURLToPath( - new URL( './playwright/global-setup.js', 'file:' + __filename ).href - ), + globalSetup: require.resolve( './playwright/global-setup.js' ), use: { baseURL: process.env.WP_BASE_URL || 'http://localhost:8889', headless: true, diff --git a/packages/scripts/config/playwright/global-setup.js b/packages/scripts/config/playwright/global-setup.js index 9a4cbde9b7d241..0a45d7335590a4 100644 --- a/packages/scripts/config/playwright/global-setup.js +++ b/packages/scripts/config/playwright/global-setup.js @@ -1,12 +1,12 @@ /** * External dependencies */ -import { request } from '@playwright/test'; +const { request } = require( '@playwright/test' ); /** * WordPress dependencies */ -import { RequestUtils } from '@wordpress/e2e-test-utils-playwright'; +const { RequestUtils } = require( '@wordpress/e2e-test-utils-playwright' ); /** * diff --git a/packages/scripts/scripts/test-playwright.js b/packages/scripts/scripts/test-playwright.js index 4c10fb6f621142..2e05d992f9df9e 100644 --- a/packages/scripts/scripts/test-playwright.js +++ b/packages/scripts/scripts/test-playwright.js @@ -41,7 +41,7 @@ const config = ! hasArgInCLI( '--config' ) && ! hasProjectFile( 'playwright.config.ts' ) && ! hasProjectFile( 'playwright.config.js' ) - ? [ '--config', fromConfigRoot( 'playwright.config.ts' ) ] + ? [ '--config', fromConfigRoot( 'playwright.config.js' ) ] : []; // Set the default artifacts path.