This directory contains Playwright end-to-end tests for the HM Query Loop plugin.
- Node.js 16+
- npm
-
Install dependencies:
npm install
-
Start the WordPress environment:
npm run wp-env start
Run all tests:
npm run test:e2eRun tests in debug mode:
npm run test:e2e:debugRun tests in watch mode (reruns on file changes):
npm run test:e2e:watchfixtures.js- Test fixtures and utilities for WordPress admin and editorposts-per-page.spec.js- Tests for the posts per page override functionality
The tests use @wordpress/env to spin up a local WordPress instance with the plugin installed. The environment configuration is in .wp-env.json.
Default ports:
- Development: http://localhost:8888
- Tests: http://localhost:8889
Tests are automatically run on GitHub Actions for pull requests and pushes to main branches. See .github/workflows/playwright-tests.yml for the configuration.
Tests use Playwright Test framework with custom WordPress fixtures. The fixtures provide utilities for:
- Admin authentication
- Creating posts/pages
- Inserting blocks
- Opening block settings
- Publishing content
Example test:
test('should show posts per page control', async ({ page, editor }) => {
await editor.createNewPost('page');
// ... test code
});If the WordPress environment fails to start, try:
npm run wp-env stop
npm run wp-env startEnsure you're running the latest version of dependencies:
npm install
npm run build
npx playwright install --with-depsIf ports 8888 or 8889 are already in use, you can change them in .wp-env.json.