Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-cypress

Package Overview
Dependencies
Maintainers
10
Versions
247
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

  • 3.13.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6K
decreased by-12.45%
Maintainers
10
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

FAQs

Package last updated on 23 Jan 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc