Socket
Book a DemoInstallSign in
Socket

gatsby-cypress

Package Overview
Dependencies
Maintainers
0
Versions
249
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-cypress

Cypress tools for Gatsby projects

latest
Source
npmnpm
Version
3.15.0
Version published
Weekly downloads
4.3K
-2.94%
Maintainers
0
Weekly downloads
 
Created
Source

gatsby-cypress

This package provides additional Cypress commands for testing Gatsby websites.

Please note: This package is not required to use Gatsby and Cypress together. It only exists to add extra commands for convenience.

If you want to find elements (e.g. by test ID or by text/label/etc.), consider using @testing-library/cypress.

Installation

To use these commands, first install the necessary packages:

npm install gatsby-cypress --save-dev

Adding custom Gatsby testing commands

Next, add a new file located at cypress/support/e2e.ts and add the Gatsby-specific Cypress commands:

import "gatsby-cypress/commands"

If you're using TypeScript, add its types to Cypress' tsconfig.json file:

{
  "compilerOptions": {
    // highlight-next-line
    "types": ["cypress", "gatsby-cypress"]
  },
  "include": ["."]
}

Once imported, the following additional commands are available:

  • cy.waitForRouteChange(): Waits for Gatsby to finish the route change, in order to ensure event handlers are properly setup. Example:

    cy.visit(`/page-2`).waitForRouteChange()
    
  • cy.waitForAPI('api-name'): Waits for a specific Gatsby API to finish. Example:

    cy.waitForAPI(`onRouteUpdate`).get(`#element-with-event-handler`).click()
    
  • cy.waitForAPIorTimeout('api-name'): Waits for a specific Gatsby API to finish. It timeouts if it doesn't finish. Example:

    cy.waitForAPIorTimeout(`onRouteUpdate`)
    

Running Cypress tests in Gatsby

Read the End-to-End Testing documentation to learn how to use Cypress and Gatsby together.

Keywords

gatsby

FAQs

Package last updated on 27 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts