There are two ways of running Playwright tests on your local machine:
If you don't have Docker, you need to install it to be able to continue with this guide. You can install it from here.
To set it up for the first time, please run this command into the root folder:
bash bin/envs/init.sh
It will create the initial Docker setup according to the same docker-compose file that runs on the CI pipeline.
To load the sample-data
environment you need to run this command:
docker-compose -f docker-compose.ci.yml run --rm -u root cli sh "/var/www/html/bin/envs/sample-data/start.sh"
Currently, we only migrated the customizer tests for which you need the sample-data
environment. As we develop more tests, you'll need to load different environments.
To run the Playwright tests, run the following command from the root folder:
yarn run test:playwright
For an accurate result, we recommend running those tests on a fresh WordPress install. To reset your WordPress instance, you can run wp db reset --yes
from the root directory of your project.
If you don't have WP CLI, you need to install it. Please follow this guide to install WP CLI.
Assuming that your local url is https://neve.test
you can run the following command from the root folder to set up the sample-data
environment:
BASE_URL=https://neve.test bash bin/envs/local.sh sample-data
Currently, we only migrated the customizer tests for which you need the sample-data
environment. As we develop more tests, you'll need to load different environments.
Assuming that your local url is https://neve.test
, navigate to e2e-tests
folder and run the following command:
baseURL=https://neve.test npx playwright test
To run a specific test you can run the following command:
baseURL=https://neve.test npx playwright test path/to/your/file.spec.ts