Add Playwright e2e hello-world test with CI job#1164
Open
PatelUtkarsh wants to merge 1 commit intocloudinary:developfrom
Open
Add Playwright e2e hello-world test with CI job#1164PatelUtkarsh wants to merge 1 commit intocloudinary:developfrom
PatelUtkarsh wants to merge 1 commit intocloudinary:developfrom
Conversation
Introduces @wordpress/e2e-test-utils-playwright (the same utilities Gutenberg uses) so future e2e coverage can build on a familiar, battle-tested foundation. - tests/e2e: playwright config, global auth setup via RequestUtils, hello-world spec covering the front page and authenticated wp-admin - package.json: test:e2e / test:e2e:debug scripts and devDeps - ci.yml: dedicated e2e job that boots wp-env (using .wp-env.json) and uploads Playwright artifacts on failure - .gitignore: ignore local Playwright output directories
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.
No linked issue. Scaffolds the foundation for e2e testing so future PRs can build on it.
Approach
@wordpress/e2e-test-utils-playwright(same utility Gutenberg uses) to keep the testing surface familiar and well-supported.tests/e2e/suite:playwright.config.js: chromium project,baseURL=http://localhost:8889(wp-env tests site), retries/traces on CI, artifacts written underartifacts/.global-setup.js: usesRequestUtilsto authenticate the defaultadmin/passwordwp-env user once and persist the auth cookies as PlaywrightstorageState, so every test starts logged in.hello-world.spec.js: two sanity checks. The front page responds with a non-empty<title>, andadmin.visitAdminPage('index.php')shows the admin bar (confirms the login/storage-state path actually works).package.json: add@playwright/testand@wordpress/e2e-test-utils-playwrightdevDeps, plustest:e2e/test:e2e:debugscripts..github/workflows/ci.yml: new dedicatede2ejob (does not touch the existingbuildmatrix). It runs checkout, Node 22,npm ci,npx playwright install --with-deps chromium,npm run build,npm run env:start(reuses the repo's existing.wp-env.json),npm run test:e2e, always stops wp-env, and uploadsartifacts/on failure..gitignore: ignore localartifacts/,playwright-report/,test-results/.QA notes
Local:
npm cinpx playwright install chromiumnpm run buildnpm run env:startnpm run test:e2e, expect2 passed.npm run env:stopVerify login actually happens (not just page-load):
artifacts/storage-states/admin.jsonshould exist and contain awordpress_logged_in_*cookie after the run.CI:
ubuntu-latest. On failure, Playwright traces/screenshots/videos are available under theplaywright-artifactsworkflow artifact.