šŸ”TOP 10 useful Cypress plugins in 2024!

Vadym Nastoiashchyi
4 min readMay 3, 2024

Cypress is a powerful JavaScript end-to-end testing tool for web applications. As with many other testing tools, Cypress allows for the use of plugins to extend its functionality, making it more robust and flexible to meet the unique demands of different testing applications.

Why Extend Cypress With Plugins?

Cypress provides an excellent out-of-the-box experience with a wide array of features. However, every testing suite has unique issues and requirements that may not be covered by the default settings. Thatā€™s where plugins come into play.

Cypress plugins enable the ability to:
- Interact with the browser at a deeper level, offering functionality that is not available in the default browser animations.
- Get more control over the Cypress server, enabling you to modify the internal behavior of Cypress.
- Extend or alter the behavior of built-in commands or add custom ones.
- Implement tasks that run within Node.js enabling you to access the file system or the database directly.

Pros of Using Cypress Plugins

Enhanced Functionality: Plugins can enhance the functionality of Cypress by adding new commands, integrating with other testing tools, or even altering how the tests run.

Customization: Plugins can be used to customize the testing environment to suit an applicationā€™s unique needs, such as setting custom environment variables, customizing error messages, or configuring advanced stubbing and spying behaviors.

Improved Efficiency: Some plugins can improve the efficiency of your tests by doing things like clearing app data between tests, automating the input of test data, or even parallelizing test runs across multiple machines.

Cons of Using Cypress Plugins

Dependency Management: Adding plugins to a project increases the number of dependencies that need to be managed and updated, which can sometimes result in version compatibility issues and increased maintenance work.

Increased Complexity: While plugins can add significant functionality, they can also make test suites more complex and harder to understand for developers not familiar with them.

Performance Impact: Using too many plugins or poorly written ones could potentially slow down the test runner, affecting the performance of your tests.

TOP 10 useful Cypress plugins in 2024:

cypress-cucumber-preprocessor

The preprocessor (with its dependencies) parses Gherkin documents and allows you to write tests as shown below.

# cypress/e2e/duckduckgo.feature
Feature: duckduckgo.com
Scenario: visiting the frontpage
When I visit duckduckgo.com
Then I should see a search bar

cypress-real-events

Cypress default events are simulated. That means that all events like cy.click or cy.type are fired from javascript. That's why these events will be untrusted (event.isTrusted will be false) and they can behave a little different from real native events. But for some cases, it can be impossible to use simulated events, for example, to fill a native alert or copy to the clipboard. This plugin solves this problem.

cypress-split

This plugin finds the Cypress specs using find-cypress-specs and then splits the list into chunks using the machine index and the total number of machines. On some CIs (GitLab, Circle), the machine index and the total number of machines are available in the environment variables. On other CIs, you have to be explicit and pass these numbers yourself.

// it works something like this:
setupNodeEvents(on, config) {
const allSpecs = findCypressSpecs()
// allSpecs is a list of specs
const chunk = getChunk(allSpecs, k, n)
// chunk is a subset of specs for this machine "k" of "n"
// set the list as the spec pattern
// for Cypress to run
config.specPattern = chunk
return config
}

eslint-plugin-cypress

An ESLint plugin for your Cypress tests.
Note: If you installed ESLint globally then you must also install eslint-plugin-cypress globally.

cypress-file-upload

File upload testing made easy.
This package adds a custom Cypress command that allows you to make an abstraction on how exactly you upload files through HTML controls and focus on testing user workflows.

cypress-axe

Test accessibility with axe-core in Cypress.

cypress-iframe

Adds iframe support to Cypress.

github-action

GitHub Action for running Cypress end-to-end and component tests. Includes npm, pnpm and Yarn installation, custom caching and lots of configuration options.

cypress-multi-reporters

Generate multiple mocha reports in a single mocha execution.

cypress-if

Easy conditional if-else logic for your Cypress tests

cy.contains('Accept cookies')
.if('visible')
.click()
.else()
.log('no cookie banner')

Cypress plugins open a new horizon of possibilities for testing web applications, enabling tailored solutions to cater to various business requirements. However, they should be picked wisely, considering their potential drawbacks. Always thoroughly assess the cost versus the benefit each plugin provides for your scenario to ensure that plugins turn out to be a helping hand rather than a stumbling block in your Cypress testing journey.

Thanks to everyone who read this article to the end, I hope you found it useful.

Sources used in the article:
https://docs.cypress.io/guides/tooling/plugins-guide

--

--