These are the docs for v2, which has an open maintenance window until April 1, 2021. View the v3 docs.

  • Gatsbyjs.com
    Gatsbyjs.com
  • Gatsby Cloud
    Gatsby Cloud
  • 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
    • v2

      • 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.

How to set up Jest for unit testing→

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.

How to test React components→

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

How to test components that use GraphQL→

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

How to test CSS-in-JS→

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

How to do visual testing with Storybook→

Storybook is a component explorer,

How to write end-to-end 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
    • How to set up Jest for unit testing
    • How to test React components
    • How to test components that use GraphQL
    • How to test CSS-in-JS
    • How to do visual testing with Storybook
    • How to write end-to-end tests with Cypress