The `netlify-plugin-cypress` package integrates Cypress end-to-end testing directly into the Netlify build pipeline. It allows developers to run Cypress tests against their deployed site (default), or earlier in the build process (preBuild, postBuild) to prevent broken deployments. The current stable version is 2.2.1, with recent updates in February 2023. This plugin differentiates itself by automating the setup and execution of Cypress within the Netlify environment, including automatically installing a Chromium browser via Puppeteer, and providing options to control when tests run relative to the deployment lifecycle. It is primarily configured via `netlify.toml`, offering a declarative way to incorporate E2E testing into continuous deployment workflows.
npm install netlify-plugin-cypressVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates installing the plugin and Cypress as dev dependencies, then configuring the plugin in `netlify.toml` to run tests after a successful deployment.
To prevent broken deploys, configure the plugin to run tests during the `preBuild` or `postBuild` phases in your `netlify.toml`. For example: `[[plugins]]
package = "netlify-plugin-cypress"
[plugins.inputs]
preBuild = "npm run cy:verify"` or leverage Cypress GitHub/GitLab/Bitbucket integration for PR status checks.Ensure you have `cypress` installed as a dev dependency: `npm install --save-dev cypress` or `yarn add -D cypress`.
If E2E test failures should block deployment, explicitly configure the plugin to run tests during the `preBuild` or `postBuild` phases in your `netlify.toml`. For example: `[[plugins]]
package = "netlify-plugin-cypress"
[plugins.inputs]
postBuild = "npm run cy:run"`.Ensure `cypress` is listed as a `devDependency` in your `package.json` and run `npm install` or `yarn install` during the Netlify build process. Also, verify `cypress` itself runs locally.
Review the Cypress test logs in your Netlify build output to identify which tests failed and why. Fix the failing tests in your codebase.
Correct your `netlify.toml` to include `package = "netlify-plugin-cypress"` within the `[[plugins]]` section, ensuring correct TOML syntax.