| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Run the setup script (downloads WordPress + the WP test suite into the repo, and creates the test DB if needed):
npm run test:setup:phpDefaults used by test:setup:php:
Override defaults via env vars (example):
WP_PHPUNIT_DB_NAME=wp_phpunit_test \
WP_PHPUNIT_DB_USER=root \
WP_PHPUNIT_DB_PASS=root \
WP_PHPUNIT_DB_HOST=127.0.0.1 \
WP_PHPUNIT_WP_VERSION=latest \
npm run test:setup:phpRun all tests:
npm run test:phpRun tests with detailed output:
npm run test:php:watchOr run PHPUnit directly:
WP_TESTS_DIR=./.wp-tests-lib src/vendor/bin/phpunit -c phpunit.xmlThe test:setup:php script will:
Run npm run test:setup:php to download the WordPress test suite.
Verify your database credentials and that MySQL is running.
Make sure the installation script is executable:
chmod +x scripts/install-wp-tests.shThe WordPress test suite download uses svn export. Install Subversion if you don't already have it.
Tests should be placed in tests/unit/ using roughly the same PSR-4 namespace structure as the PHP source files.
Example test:
<?php
namespace Code_Snippets\Controller;
use Code_Snippets\UnitTestCase;
class Example_Controller_Test extends UnitTestCase {
public function test_something() {
$this->assertTrue( true );
}
}Prerequisites:
Install JavaScript dependencies:
npm ciInstall Playwright browsers (once):
npx playwright installStart the WordPress environment:
npm run wp-env:startOptional (recommended when switching branches / after failures): reset the WP env:
npm run wp-env:clean
npm run wp-env:startPrepare the environment for E2E (cleans stale flat-file artifacts, ensures plugin active, etc.):
npm run test:setup:playwrightRun everything:
npm run test:playwrightRun a single project:
npm run test:playwright -- --project=chromium-db-snippetsRun the file-based snippets project (includes flat-file setup):
npm run test:playwright -- --project=chromium-file-based-snippetsRun with HTML reporter but don’t auto-open the report:
PW_TEST_HTML_REPORT_OPEN=never npm run test:playwrightnpx playwright show-trace test-results/**/trace.zipGuidelines / caveats:
| Back | FazBrowse Home | New Git URL |