This guide follows the WooCommerce guide to unit tests.
- From the plugin directory, run
npm run up
ordocker compose up -d
- Once the containers are up, run the tests from the plugin root directory using
npm test
- Tests can be run in watch mode using
npm run test:watch
andnpm run test:php-watch
for JavaScript and PHP unit tests respectively
- From the plugin directory, run
composer install
if you have not already:
$ composer install
- Install WordPress and the WP Unit Test lib using the
bin/install-wp-tests.sh
script. From the plugin root directory type:
$ bin/install-wp-tests.sh <db-name> <db-user> <db-password> [db-host]
Tip: try using 127.0.0.1
for the DB host if the default localhost
isn't working.
- Run the tests from the plugin root directory using
$ ./vendor/bin/phpunit