node
, npm
, docker
, docker-compose
installed.
- Create a
scripts/.secrets
file, based onsecrets/.secrets-sample
- Add
newspack-e2e.com
to hosts file (add a line with127.0.0.1 newspack-e2e.com
) - Start docker-compose:
$ docker-compose up --build
- In a new terminal session, run setup script in the container:
$ npm run wp:setup
- Start Cypress:
- no UI, run headless -
$ npm run test:ci
- with Cypress UI -
$ npm run test
Run $ npm run wp:reset
to reset the WP DB and re-run setup script.
For a real hard reset, stop the docker-compose
process, remove containers (docker-compose down --volumes
), and repeat the initial setup form above.
- Remove the
./wordpress/wp-content/plugins/newspack-plugin
- Sync the local content to the Docker container volume:
$ rsync -a --exclude-from='.distignore' . /path/to/newspack-e2e-tests/wordpress/wp-content/plugins/newspack-plugin
Pro tip: use chokidar to sync local repository to the Docker machine, by running this in the plugin folder:
$ chokidar "." -c "rsync -a --exclude-from='.distignore' . /path/to/newspack-e2e-tests/wordpress/wp-content/plugins/newspack-plugin"
There are three "testing channels" available, meaning three sources for the Newspack plugins:
- Stable releases channel – versions currently distributed on Github
master
branches channel – versions built frommaster
branchesalpha
branches channel – versions currently distributed on Github as pre-releases
The CI for this project should be configured to run tests periodically – after release days for the stable & alpha
channels, and daily for master
branches channel.
The stable channel is the default. To use a different channel while developing tests locally, add TEST_CHANNEL
variable in scripts/.env
.
Not ready yet for running on CI. Due to font differences the results fail.
After adding a new visual regression test, run $ npm run test:visual:setup
to create the base images.
To check for visual regressions, run $ npm run test:visual:check
.
The images are stored in cypress/snapshots/base
. After a test run, the image diffs will be stored in cypress/snapshots/diff
- in case of tests failing on visual check, inspect those for the regressions.
The visual regression testing is set up to run in Electron browser in order to achieve same results locally and on CI (where Electron is the only available option).
Note that Cypress UI will disappear momentarily when taking a screenshot.
- After each test run, a video of the test will be stored in
artifacts/video
- Enter the WordPress docker container with
docker exec -it wordpress_local /bin/bash
- the WP CLI will be installed.- all
wp
commands have to be ran with--allow-root
option
- all
- WP is available locally at
https://newspack-e2e.com
If SLACK_CHANNEL_ID
and SLACK_AUTH_TOKEN
environment variables are set on the CI environment, the selected Slack channel will be updated whenever a test suite fails.