Repository navigation
Move the test environment into its own wp-env configuration - #24
Merged
Merged
Conversation
`wp-env` deprecated starting a tests environment alongside the development one
from a single configuration file, and says so on every start:
⚠ Warning: wp-env starts both development and tests environments by default.
This behavior is deprecated and will be removed in a future version.
The "env", "testsPort", and "testsEnvironment" options are also deprecated.
Use the --config option with a separate config file for test environments.
Both suites run against that tests environment, so the replacement is a second
configuration file: `.wp-env.test.json` describes the environment the tests use,
keeps port 8891, and is started with `wp-env start --config=.wp-env.test.json`.
`.wp-env.json` keeps the development site on port 8890 and now sets
`"testsEnvironment": false`, which is what silences the warning. Each
configuration file gets its own containers and its own database, so the
isolation the two environments provided is unchanged.
With the tests environment in its own file, its WP-CLI container is the plain
`cli` service of that configuration rather than `tests-cli`, so the npm scripts
and `tests/e2e/wp-cli.js` address it with `--config` instead.
`playwright.config.js` now sets `WP_BASE_URL` itself. This is not cosmetic:
`wp-scripts test-playwright` derives that variable from `env.tests.port` of the
default configuration, which no longer describes a tests environment — the base
configuration would otherwise fall back to its own default of
`http://localhost:8889` and every test would fail to connect. The port is read
from `.wp-env.test.json` so it stays a single source of truth, and an explicitly
exported `WP_BASE_URL` still wins.
The E2E workflow writes its core-version override to `.wp-env.test.override.json`,
the override file name `wp-env` derives for that configuration.
Verified locally against the split configuration: `env:test:start` reports no
deprecation warning, the site answers on port 8891, the integration suite passes
single site and multisite (8 tests, 15 assertions each), and the E2E suite passes
in Chromium.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wp-envdeprecated starting a tests environment alongside the development one from a single configuration file, and says so on every start:Both suites run against that tests environment, so the replacement is a second configuration file.
.wp-env.test.jsondescribes the environment the tests use, keeps port 8891, and is started withwp-env start --config=.wp-env.test.json..wp-env.jsonkeeps the development site on port 8890 and now sets"testsEnvironment": false, which is what silences the warning. Each configuration file gets its own containers and its own database, so the isolation the two environments provided is unchanged.With the tests environment in its own file, its WP-CLI container is the plain
cliservice of that configuration rather thantests-cli, so the npm scripts andtests/e2e/wp-cli.jsaddress it with--configinstead. Newenv:test:start,env:test:stopandenv:test:destroyscripts sit alongside the development ones, and both workflows use them.The one non-obvious part
playwright.config.jsnow setsWP_BASE_URLitself. This is not cosmetic:wp-scripts test-playwrightderives that variable fromenv.tests.portof the default configuration, which no longer describes a tests environment — without it the base configuration falls back to its own default ofhttp://localhost:8889and every test fails to connect. The port is read from.wp-env.test.jsonso it stays a single source of truth, and an explicitly exportedWP_BASE_URLstill wins.The E2E workflow writes its core-version override to
.wp-env.test.override.json, the override file namewp-envderives for that configuration.Verification
Run locally against the split configuration before pushing:
npm run env:test:starthttp://localhost:8891, no deprecation warningnpm run test:integrationnpm run test:integration:multisitenpm run test:e2eCI additionally covers the
.wp-env.test.override.jsonrename, which is what selects WordPress 7.1 and trunk in the E2E matrix.🤖 Generated with Claude Code