cypress-io/eslint-plugin-cypress

Enforce Cypress listener rules

Open

#321 opened on Apr 3, 2026

 (1 comment) (0 reactions) (0 assignees)JavaScript (95 forks)auto 404
good first issue

Repository metrics

Stars
 (728 stars)
PR merge metrics
 (PR metrics pending)

Description

Problems

  1. I noticed in a project that there was a Cypress.on listener defined in a beforeEach, yet no Cypress.off to remove it, so the listener is added each time the beforeEach runs.

cy.on listeners are cleaned up before tests, but Cypress.on need to be unregistered when they're no longer needed.

beforeEach(function () {
  Cypress.on('uncaught:exception', (err, runnable) => {
    return false
  })
})
  1. I also saw a case where a Cypress.on listener was defined in a test, where it was assumed it was scoped to that single test, but it was applying throughout the session. So other tests where the listener was not intended to suppress the uncaught:exception events were being mistakenly suppressed (potentially not catching bugs)

  2. Cypress commands don't execute within Cypress.on listeners and there should be an error when people try to do this because it does nothing. https://github.com/cypress-io/cypress/issues/6316

What's needed

Suggest creating some eslint rules to enforce good Cypress listener rules to address these.

Contributor guide