Skip to content
Open
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
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
# - '{version}': any major.minor PHP version from 5.2 onwards.
##

# The site will be available at http://localhost:LOCAL_PORT
# The development site will be available at http://localhost:LOCAL_PORT. E2E uses
# LOCAL_PORT + 1 unless LOCAL_E2E_PORT is provided at runtime or in this file.
LOCAL_PORT=8889
LOCAL_E2E_PORT=

# Where to run WordPress from. Valid options are 'src' and 'build'.
LOCAL_DIR=src
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Configuration files with possibly sensitive information
.env
wp-config.php
/wp-config-e2e*
wp-tests-config.php
.htaccess

Expand Down Expand Up @@ -47,6 +48,8 @@ wp-tests-config.php
/packagehash.txt
/.gutenberg-hash
/artifacts
/tests/e2e/.database-state.json
/tests/e2e/.database-lock*
/setup.log
/coverage

Expand Down Expand Up @@ -76,6 +79,7 @@ wp-tests-config.php
!/src/wp-content/themes/ipsum
/src/wp-content/upgrade
/src/wp-content/uploads
/src/wp-content/uploads-e2e
/src/wp-content/advanced-cache.php
/src/wp-content/blog-deleted.php
/src/wp-content/blog-inactive.php
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:

ports:
- ${LOCAL_PORT-8889}:80
- ${LOCAL_E2E_PORT:-8890}:80

environment:
LOCAL_DIR: ${LOCAL_DIR-src}
Expand Down Expand Up @@ -161,6 +162,14 @@ services:
php:
condition: service_started

memcached-e2e:
image: memcached

networks:
- wpdevnet

command: memcached -m 64

volumes:
# So that sites aren't wiped every time containers are restarted, MySQL uses a persistent volume.
mysql: {}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
"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:config && wp-scripts test-playwright --config tests/e2e/playwright.config.js",
"test:e2e:config": "node --test tests/e2e/config/database.test.cjs",
"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
12 changes: 8 additions & 4 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ End-To-End (E2E) tests for WordPress.

## Running the tests

The 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`.
The e2e tests require a production-like environment to run. By default, the development site remains at `http://localhost:8889`, and the E2E site uses the next port, `http://localhost:8890`. The E2E port defaults to `LOCAL_PORT + 1`; set `LOCAL_E2E_PORT` to choose another port. Both sites use the configured `LOCAL_DIR` tree.

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).

Expand All @@ -17,12 +17,16 @@ 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:
The E2E site has its own `wp-config-e2e.php`, `wordpress_develop_e2e` database, `uploads-e2e` directory, and Memcached service when persistent caching is enabled. The development URL keeps using its original database and configuration throughout the run. E2E setup restores its temporary host-and-port routing after the tests.

If using a custom URL, it must point to an isolated WordPress test site with a disposable database and uploads directory. Set `WP_E2E_ISOLATED=true` to confirm that setup, along with the base URL, username and password. Playwright will use that site without starting the local Docker environment:

```
WP_BASE_URL=http://mycustomurl WP_USERNAME=username WP_PASSWORD=password npm run test:e2e
WP_BASE_URL=http://mycustomurl WP_USERNAME=username WP_PASSWORD=password WP_E2E_ISOLATED=true npm run test:e2e
```
**DO NOT run these tests in an actual production environment, as they will delete all your content.**
The E2E setup clears test posts, blocks, and preferences. Do not point it at a production or development site.

The local E2E setup holds a lock while it prepares the separate site configuration. A second E2E run in the same checkout exits before changing configuration. Interrupted runs restore the routing and regenerate the E2E config, including its original table prefix. PHPUnit continues to use `wordpress_develop_tests`.

For debugging purposes, you might want to follow the test visually. You can do so by running the tests in an interactive mode:

Expand Down
Loading
Loading