Skip to content

Move the test environment into its own wp-env configuration - #24

Merged
2ndkauboy merged 1 commit into
developfrom
ci/wp-env-parallel-config
Sep 13, 2026
Merged

2ndkauboy merged 1 commit into
developfrom
ci/wp-env-parallel-config

Conversation

@2ndkauboy

Copy link
Copy Markdown
Owner

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

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. New env:test:start, env:test:stop and env:test:destroy scripts sit alongside the development ones, and both workflows use them.

The one non-obvious part

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 — without it the base configuration falls back to its own default of http://localhost:8889 and every test fails 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.

Verification

Run locally against the split configuration before pushing:

result
npm run env:test:start site at http://localhost:8891, no deprecation warning
npm run test:integration OK (8 tests, 15 assertions)
npm run test:integration:multisite OK (8 tests, 15 assertions)
npm run test:e2e 1 passed, chromium

CI additionally covers the .wp-env.test.override.json rename, which is what selects WordPress 7.1 and trunk in the E2E matrix.

🤖 Generated with Claude Code

`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>
@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@2ndkauboy
2ndkauboy merged commit bc8bb44 into develop Sep 13, 2026
4 checks passed
@2ndkauboy
2ndkauboy deleted the ci/wp-env-parallel-config branch September 13, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant