Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Test Gatsby Websites: Components, GraphQL, E2E, and Accessibility

A practical Gatsby testing guide: configure Jest, test query-driven components, run Cypress or Playwright against a production build, and combine automated accessibility scans with manual checks.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test a Gatsby site in layers: use Jest and React Testing Library for component behavior, supply representative GraphQL data for query-dependent components, and use Cypress or Playwright for browser journeys. In CI, build and serve the production site before running end-to-end tests, then add automated and manual accessibility checks.

Choose tests by what can fail

A useful Gatsby test strategy is a pyramid, not a choice between unit tests and browser tests. Keep detailed state and rendering checks fast and isolated; reserve browser automation for the integrations and user journeys that need a real browser.

As an Amazon Associate I earn from qualifying purchases.

Layer What it checks Best fit
Unit and component Rendering, states, and component behavior in isolation Many variations that should produce quick feedback
Query-aware component Components that depend on Gatsby GraphQL query results Representative data inputs for Gatsby-specific components
End-to-end (E2E) Visible behavior across pages, browser interactions, and integrations Critical journeys where the pieces must work together
Accessibility checks Known rule violations and user-facing accessibility behavior A repeatable quality layer across components and browser flows, supplemented by manual checks

Gatsby’s documentation covers Jest setup, Cypress-based E2E testing, and accessibility practices; it also identifies Playwright as a popular E2E alternative. Gatsby’s unit testing guide notes that unit testing is not included out of the box.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set up unit and component tests

Configure Jest for Gatsby

Gatsby’s documented setup assumes Jest 29 or newer. Install Jest, babel-jest, babel-preset-gatsby, and identity-obj-proxy, then configure Jest to use Gatsby’s Babel preset and a preprocessing file. The preset matters because Gatsby’s internal transforms differ from a standard React project.

Also map static assets and styles to mocks, ignore Gatsby’s .cache directory, and allow Gatsby’s untranspiled dependencies to be transformed. Without that configuration, Jest may fail to parse framework code in node_modules. Use React Testing Library to render components and exercise their behavior. Follow the current Gatsby unit testing instructions for the configuration details relevant to your project.

Keep component tests focused

Use component tests to cover meaningful states and interactions without starting the whole site. For example, a navigation component can be checked for its links and expanded or collapsed state; a content card can be checked with different titles or missing optional fields. Avoid duplicating a full browser journey in component tests: that belongs in E2E coverage.

Test components that use GraphQL data

Gatsby query-dependent components need realistic query results in tests. The community plugin gatsby-plugin-testing provides one Gatsby-specific option: it saves static query results in .testing-static-queries.json when you run gatsby build or gatsby develop. Its documentation also describes snapshots that freeze query inputs and can allow tests to run without a Gatsby build.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Add the plugin and follow its setup instructions for your Gatsby project.
  2. Run gatsby build or gatsby develop to generate stored query data before tests that use it.
  3. After editing a query, rebuild the data. Otherwise tests may silently use stale results and pass against inputs that no longer reflect the query.
  4. Consider ignoring .testing-static-queries.json in Git, or use the plugin’s snapshot approach when frozen inputs or CI independence are more useful.

The plugin is community-maintained, and its documentation does not provide a current Gatsby-version compatibility matrix. Check that it is maintained and compatible with your Gatsby version before adopting it. See gatsby-plugin-testing documentation for its supported workflow.

Run end-to-end tests in a browser

Use browser tests for consequential user journeys: moving between generated pages, following content links, submitting forms, using search or filtering where present, and interacting with menus or other controls. Cypress is the framework used in Gatsby’s walkthrough; Playwright is another option. E2E tests give confidence in integrated, user-visible behavior, but require more setup and maintenance than isolated component tests.

Use Gatsby’s development loop while authoring

Gatsby’s Cypress guide demonstrates start-server-and-test to start gatsby develop, wait for the local server, and then launch Cypress. This is convenient for developing tests. Use cypress open for interactive authoring; in CI, use cypress run.

If the development server runs with Gatsby’s --https option, the guide says start-server-and-test may wait indefinitely unless you set START_SERVER_AND_TEST_INSECURE=1.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test the production build in CI

For deployment-like confidence, Gatsby recommends testing a production build rather than relying only on the development server. Build the site, serve that build, and run Cypress against it:

  1. Run gatsby build to create the production output.
  2. Run gatsby serve to serve the built site locally.
  3. Wait for the served site to be ready, then run cypress run against it.

The exact CI orchestration depends on your environment, but the key is to point browser tests at the served production build. Gatsby’s end-to-end testing guide documents the Cypress workflow and its development-server caveat.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Add accessibility checks, then test manually

Gatsby enables eslint-plugin-jsx-a11y warnings by default, which can identify some code-level problems. Add automated scans for repeatable regressions: Gatsby’s E2E guide demonstrates cypress-axe, which brings axe-powered checks into browser tests. Automated tools detect violations from known rule sets; they cannot prove that a page is fully accessible.

Manually check the parts automation cannot reliably judge in context:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Navigate the site with a keyboard and confirm visible focus.
  • Check contrast, zoom, and magnification.
  • Verify semantic headings and landmarks, accessible forms, and text alternatives for media.
  • Operate menus, modals, and custom widgets using the relevant interaction patterns.

Gatsby’s accessibility checklist recommends a mix of keyboard review and tools such as Lighthouse, axe, and Accessibility Insights. Cypress also explains the limits of automated checks in its accessibility testing guide.

Where screenshots fit into Gatsby testing

A screenshot is useful when a test needs a visual artifact—for example, to inspect a rendered page or capture a result for a separate review process. It does not replace assertions about navigation, interactions, query data, or accessibility. Gatsby’s testing guides focus on Jest, browser automation, and accessibility rather than prescribing a screenshot API.

Or skip the browser setup

If you need a screenshot of a Gatsby page without configuring browser capture locally, ScreenshotNeo accepts one GET request and returns an image or PDF. For example, this cURL request saves a WebP screenshot; replace the URL with the Gatsby page you want to capture:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.