Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

  • Gatsbyjs.com
    Gatsbyjs.com
  • Gatsby Cloud
    Gatsby Cloud
  • Documentation
    Documentation
  • Support
    Support
  • Contact
    Contact
  • Log in
    Log in
docs
    • Tutorial
      Tutorial
    • How-to Guides
      How-to Guides
    • Reference
      Reference
    • Conceptual Guide
      Conceptual Guide
    • Quick Start
      Quick Start
    • v3

      • v4 (beta)

        v4 (beta)

      • v3

        v3

      • v2

        v2

      • v1

        v1

DocumentationHow-to Guides
Docs

Testing

One of the benefits of building a Gatsby project is the ability to add automated tests for your components, APIs, pages, and more. With Gatsby, you can employ modern tooling like Jest and Cypress (or other tools of your choosing) to build a robust React web application.

This section covers common tools and setup instructions for adding testing functionality to your Gatsby project.

Jest→

Unit testing protects against unexpected behavior in your code. Walk through a few extra steps you'll need to set up Jest, a popular Javascript testing framework, with Gatsby.

React components→

Install and use react-testing-library, the most popular framework for testing the behavior of React components.

GraphQL→

Mocking syntax and testing the output of components that get their data from GraphQL.

CSS-in-JS→

Use snapshot serializers to ensure that presentational components built using styled-components or emotion render correctly when given different inputs

Visual testing with Storybook→

Storybook is a component explorer,

E2E tests with Cypress→

End-to-end testing enable automated checks that specific user flows through one or many pages work as expected.

  • Accessibility Statement
  • Code of Conduct
  • Logo & Assets
  • Privacy Policy
  Docs
  • How-to Guides
    • Overview
    • Overview
    • Jest
    • React components
    • GraphQL
    • CSS-in-JS
    • Visual testing with Storybook
    • E2E tests with Cypress