Tests: Fix wp-env scripts not found in test workspaces#77055
Tests: Fix wp-env scripts not found in test workspaces#77055manzoorwanijk merged 1 commit intotrunkfrom
Conversation
After #74684 converted test directories to workspaces, Playwright's webServer command `npm run wp-env-test` fails because the script is only defined in the root package.json. Use `--prefix ../..` to run the root scripts from the workspace context.
|
Size Change: 0 B Total Size: 7.74 MB ℹ️ View Unchanged
|
|
Flaky tests detected in a91ed35. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24030723346
|
Mamaduka
left a comment
There was a problem hiding this comment.
Can confirm that this fixes the issue ✅ Thanks, @manzoorwanijk!
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
What?
Follow-up fix to #74684.
After converting test directories to workspaces, running
npm run test:e2elocally fails withMissing script: "wp-env-test".Why?
Playwright's
webServer.commandrunsnpm run wp-env-test -- start, butwp-env-testis only defined in the rootpackage.json. When npm executes the test command from the workspace directory (test/e2e/), it can't find the script.The same issue affects
test/performance/, where the base Playwright config'snpm run wp-env startwould also fail from the workspace context.How?
Use
npm run --prefix ../..to explicitly run the root-level wp-env scripts from the workspace directories:test/e2e/playwright.config.ts:npm run --prefix ../.. wp-env-test -- starttest/performance/playwright.config.ts:npm run --prefix ../.. wp-env -- startTesting Instructions
npm run test:e2e— should no longer fail with "Missing script: wp-env-test"wp-envrunning (npm run wp-env-test -- start)