NPM package to set up boilerplate for Cypress testing.
The script will do everything required: install dependencies, add scripts to your package.json and create some files required to run Cypress and wp-env.
# Go to your project folder
cd ~/my-plugin
# (Optional) Initialize NPM if not yet
npm init
# Run the boilerplate script
npx github:10up/cypress-wp-setup
Now you are able to manage wp-env and run Cypress tests.
Always use this command to start the environment in GitHub Actions because it will apply the fix to make permalinks working.
npm run env:start
This is a shortcut to wp-env:
npm run env
./tests/bin/set-core-version.js <version>
<version>
might be:
latest
to use current WordPress releasemaster
to use nightly build5.9
to specify a version
Numeric version should match existing tags in WordPress repository.
# Run tests
npm run cypress:run
# Or open debug Chromium
npm run cypress:open
The boilerplate includes a single basic example test.
The setup includes Cypress WP Utils library with a set of Cypress commands designed to write tests for WordPress.
cy.login();
cy.activatePlugin("my-plugin");
cy.createPost({
title: "Post Title",
content: 'Test Content',
});
The distribution includes the config for GitHub Actions in .github/workflows/cypress.yml
. It will install dependencies, run wp-env, and perform tests.
You can specify WordPress versions to test against in the matrix:
strategy:
matrix:
core:
- {name: 'WP latest', version: 'latest'}
- {name: 'WP minimum', version: 'WordPress/WordPress#5.2'}
- {name: 'WP trunk', version: 'WordPress/WordPress#master'}
The job includes 2 optional steps, you can update them and make required (removing continue-on-error
flag):
- name: Composer (optional)
run: composer install
continue-on-error: true
- name: Build (optional)
run: npm run build
continue-on-error: true
Beta: This project is quite new and we're not sure what our ongoing support level for this will be. Bug reports, feature requests, questions, and pull requests are welcome. If you like this project please let us know, but be cautious using this in a Production environment!
Please read CODE_OF_CONDUCT.md for details on our code of conduct, CONTRIBUTING.md for details on the process for submitting pull requests to us, and CREDITS.md for a list of maintainers, contributors, and libraries used in this repository.