This package, `cypress-wp-test-utils`, provides a comprehensive collection of custom Cypress commands specifically designed for robust end-to-end testing of WordPress applications. It streamlines interactions with the WordPress admin area and the Gutenberg editor, offering high-level commands such as `loginUser`, `createNewPost`, `insertBlock`, `activatePlugin`, and `clickBlockToolbarButton`. Inspired by `@wordpress/e2e-test-utils` (which targets Puppeteer), this library serves a similar purpose for Cypress users, abstracting complex WordPress-specific DOM interactions. The current stable version is 1.0.0. The project maintains a regular release cadence, primarily focusing on compatibility with new major versions of Cypress and WordPress, alongside bug fixes and new feature introductions. Its key differentiator is providing a focused, high-level API for common WordPress testing scenarios directly within a Cypress test suite, significantly reducing boilerplate and improving test readability.
npm install cypress-wp-test-utilsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to register and use core commands for logging into WordPress, creating a new post, and activating a plugin within a Cypress test suite. It includes best practices for handling credentials.
Remove any `wpVersion` entries from your Cypress configuration's `env` variables (e.g., `cypress.json` or `cypress.config.js`). The functionality is now handled internally.
Ensure `@cypress/xpath` is installed (`npm install -D @cypress/xpath`) and registered in your `cypress/support/e2e.ts` (or `index.js`) if you require `cy.xpath()` for non-library-specific uses. No direct action is required for `cypress-wp-test-utils` commands.
Install Cypress in your project: `npm install cypress --save-dev` or `yarn add cypress --dev`.
Add `import { registerWpTestCommands } from 'cypress-wp-test-utils'; registerWpTestCommands();` to your Cypress support file.Ensure `registerWpTestCommands()` is called in your Cypress support file (e.g., `cypress/support/e2e.ts` or `cypress/support/index.js`).
Remove the `wpVersion` entry from the `cypress-wp-test-utils` section of your Cypress configuration (`cypress.json` or `cypress.config.js`). The library handles WordPress version compatibility automatically.
Install `@cypress/xpath` (`npm install -D @cypress/xpath`) and ensure it's imported in your Cypress support file: `import '@cypress/xpath';`.
Ensure the package is installed: `npm install cypress-wp-test-utils --save-dev` or `yarn add cypress-wp-test-utils --dev`. Verify the import path in your code.