Chapter 11. Debugging and Testing Gatsby

Once your Gatsby implementation is complete, you’ll often find that you need to troubleshoot some issues before you can deploy your site to production. In Gatsby, it’s possible to do test-driven development (TDD) by writing unit tests in Jest and performing tests on various aspects of the development experience.

Even with a robust test architecture, however, sometimes Gatsby sites fail for obscure reasons and require a deeper level of troubleshooting and debugging. Fortunately, the Gatsby ecosystem provides a variety of tools for testing your sites ahead of time to help you avoid problems and debug them when issues arise. Before your site can go into production, it’s essential to ensure that it functions the way you intend.

In this chapter, we’ll cover testing strategies, including unit testing and component-level testing, and debugging tactics, including for static builds, server-side rendering issues, and other issues that arise during development.


Sometimes during development, it will be useful to spin up a local development server that provides local HTTPS support. For more information, consult the Gatsby documentation’s guide to local HTTPS.

Testing Gatsby

Gatsby enables unit testing—testing that evaluates atomic units of functionality—with limited additional setup through Jest. The Jest framework can be used on its own for snapshot testing—testing that compares visual states of the application to track regressions in the user ...

Get Gatsby: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.