Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/reusable-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ jobs:
# - Uploads screenshots and HTML snapshots as an artifact.
# - Ensures version-controlled files are not modified or deleted.
e2e-tests:
name: SCRIPT_DEBUG ${{ inputs.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }}
name: ${{ matrix.project }} / SCRIPT_DEBUG ${{ inputs.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }}
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# See the "Projects" section in tests/e2e/README.md.
project: [ 'parallel', 'serial' ]

steps:
- name: Configure environment variables
Expand Down Expand Up @@ -147,8 +152,9 @@ jobs:
npm run env:cli -- language theme install de_DE --all --path="/var/www/${LOCAL_DIR}"

- name: Run E2E tests
run: npm run test:e2e
run: npm run "test:e2e:${PROJECT}"
env:
PROJECT: ${{ matrix.project }}
# Chromium is installed above and is the only browser the suite runs. Without this,
# `wp-scripts test-playwright` also downloads Firefox and WebKit on every run.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: ${{ inputs.install-playwright && '1' || '' }}
Expand All @@ -157,7 +163,7 @@ jobs:
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: failures-artifacts${{ inputs.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }}
name: failures-artifacts-${{ matrix.project }}${{ inputs.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }}
path: artifacts
if-no-files-found: ignore
include-hidden-files: true
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@
"test:performance": "wp-scripts test-playwright --config tests/performance/playwright.config.js",
"test:php": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit",
"test:coverage": "npm run test:php -- --coverage-html ./coverage/html/ --coverage-php ./coverage/php/report.php --coverage-text=./coverage/text/report.txt",
"test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js",
"test:e2e": "npm run test:e2e:parallel && npm run test:e2e:serial",
"test:e2e:parallel": "wp-scripts test-playwright --config tests/e2e/playwright.config.js --project=parallel",
"test:e2e:serial": "wp-scripts test-playwright --config tests/e2e/playwright.config.js --project=serial",
"test:visual": "wp-scripts test-playwright --config tests/visual-regression/playwright.config.js",
"typecheck:php": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan --",
"typecheck:php:baselines": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan:baselines --",
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# E2E TestsEnd-To-End (E2E) tests for WordPress.## Running the testsThe e2e tests require a production-like environment to run. By default, they will assume an environment is available at `http://localhost:8889`, with username `admin` and password `password`.If you don't already have an environment ready, you can set one up by following [these instructions](https://github.com/WordPress/wordpress-develop/blob/master/README.md).Then you can launch the tests by running:```npm run test:e2e```which will run the test suite using a headless browser.If your environment has a different url, username or password to the default, you can provide the base URL, username and password like this:```WP_BASE_URL=http://mycustomurl WP_USERNAME=username WP_PASSWORD=password npm run test:e2e```**DO NOT run these tests in an actual production environment, as they will delete all your content.**For debugging purposes, you might want to follow the test visually. You can do so by running the tests in an interactive mode:```npm run test:e2e -- --ui```[UI Mode](https://playwright.dev/docs/test-ui-mode) let's you explore, run and debug tests with a time travel experience complete with watch mode.All test files are loaded into the testing sidebar where you can expand each file and describe block to individually run, view, watch and debug each test.You can also run a single test file separately:```npm run test:e2e tests/e2e/specs/hello.test.js```## Documentation* Block Editor Handbook end to end testing overview: https://developer.wordpress.org/block-editor/contributors/code/testing-overview/#end-to-end-testing* Gutenberg e2e-test-utils-playwright package API docs: https://github.com/WordPress/gutenberg/tree/trunk/packages/e2e-test-utils-playwright* Playwright API docs: https://playwright.dev/docs (the version we are using is indicated in the `@wordpress/scripts` package: https://github.com/WordPress/gutenberg/blob/trunk/packages/scripts/package.json)
# E2E TestsEnd-To-End (E2E) tests for WordPress.## Running the testsThe e2e tests require a production-like environment to run. By default, they will assume an environment is available at `http://localhost:8889`, with username `admin` and password `password`.If you don't already have an environment ready, you can set one up by following [these instructions](https://github.com/WordPress/wordpress-develop/blob/master/README.md).Then you can launch the tests by running:```npm run test:e2e```which will run the test suite using a headless browser.If your environment has a different url, username or password to the default, you can provide the base URL, username and password like this:```WP_BASE_URL=http://mycustomurl WP_USERNAME=username WP_PASSWORD=password npm run test:e2e```**DO NOT run these tests in an actual production environment, as they will delete all your content.**For debugging purposes, you might want to follow the test visually. You can do so by running the tests in an interactive mode:```npm run test:e2e -- --ui```[UI Mode](https://playwright.dev/docs/test-ui-mode) let's you explore, run and debug tests with a time travel experience complete with watch mode.All test files are loaded into the testing sidebar where you can expand each file and describe block to individually run, view, watch and debug each test.You can also run a single test file separately:```npm run test:e2e tests/e2e/specs/hello.test.js```## ProjectsThe suite has two Playwright projects, defined in `playwright.config.js`. `npm run test:e2e` runs `parallel`, then `serial`.* `parallel` (`npm run test:e2e:parallel`): specs that can share the site with other tests. Spec files run at the same time on several workers, one for every two CPU cores. Tests inside one file still run in order.* `serial` (`npm run test:e2e:serial`): specs that break the site for other tests. They run one at a time on one worker.New specs go in `parallel` by default. Add a spec to `SERIAL_SPECS` only if it makes the site unusable for other tests, or if it changes content or settings that other tests use, for example with `requestUtils.deleteAllPosts()`.## Documentation* Block Editor Handbook end to end testing overview: https://developer.wordpress.org/block-editor/contributors/code/testing-overview/#end-to-end-testing* Gutenberg e2e-test-utils-playwright package API docs: https://github.com/WordPress/gutenberg/tree/trunk/packages/e2e-test-utils-playwright* Playwright API docs: https://playwright.dev/docs (the version we are using is indicated in the `@wordpress/scripts` package: https://github.com/WordPress/gutenberg/blob/trunk/packages/scripts/package.json)
Expand Down
35 changes: 34 additions & 1 deletion tests/e2e/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import path from 'node:path';
import { defineConfig } from '@playwright/test';
import { defineConfig, devices } from '@playwright/test';

/**
* WordPress dependencies
Expand All @@ -15,13 +15,46 @@ process.env.STORAGE_STATE_PATH ??= path.join(
'storage-states/admin.json'
);

const SERIAL_SPECS = [
'install.test.js',
'maintenance-mode.test.js',
'fatal-error-handler.test.js',
'login-localize-script.test.js',
'gutenberg-plugin.test.js',
'plugins.test.js',
// These delete all posts or media, including other workers' content.
'cache-control-headers-directives.test.js',
'dashboard.test.js',
'edit-posts.test.js',
'empty-trash-restore-trashed-posts.test.js',
'media-library-client-side-upload.test.js',
'media-modal-client-side-upload.test.js',
'media-new-client-side-upload.test.js',
];

const config = defineConfig( {
...baseConfig,
globalSetup: require.resolve( './config/global-setup.js' ),
workers: '50%',
webServer: {
...baseConfig.webServer,
command: 'npm run env:start',
},
projects: [
{
name: 'parallel',
testIgnore: SERIAL_SPECS,
fullyParallel: false,
use: { ...devices[ 'Desktop Chrome' ] },
},
{
name: 'serial',
testMatch: SERIAL_SPECS,
fullyParallel: false,
workers: 1,
use: { ...devices[ 'Desktop Chrome' ] },
},
],
} );

export default config;
Loading