1. PHP Unit Tests
Using PHPUnit, these tests cover everything from WordPress APIs and classes to custom filters and hooks.
They answer questions like:
- Does this function return the expected result?
- What happens when an edge case is passed in?
Location: tests/phpunit/tests/
Command: npm run test:php
2. JavaScript Unit Tests (QUnit)
These test interactive parts of the admin dashboard and Gutenberg editor. They validate UI elements, AJAX responses, and DOM manipulations.
Location: src/js/_enqueues/tests/
Command: npm run test:js
3. End-to-End (E2E) Tests
Simulate actual user behavior across the full application. Use cases include:
- Creating a post and verifying its display
- Uploading media and checking image rendering
- Logging in and navigating menus
Tools: Playwright (moving from Puppeteer)
Command: npm run test:e2e
4. Integration Tests
Integration tests ensure different parts of the stack work together, like:
- How REST API endpoints behave when accessed via AJAX
- Whether the customizer reflects database changes instantly
5. Coding Standards (Linters)
Linters catch stylistic and structural inconsistencies before runtime bugs even occur. WordPress follows strict coding standards for PHP, JS, and CSS.
Tools:
- PHP_CodeSniffer
- eslint
- stylelint
Command: npm run lint:all
Leave a Reply