small medium large xlarge

Test-Driven React: Find Problems Early, Fix Them Quickly, Code with Confidence


Cover image for Test-Driven React

Test-Driven React

Find Problems Early, Fix Them Quickly, Code with Confidence


You work in a loop: write code, get feedback, iterate. The faster you get feedback, the faster you can learn and become a more effective developer. Test-Driven React helps you refine your React workflow to give you the feedback you need as quickly as possible. Write strong tests and run them continuously as you work, split complex code up into manageable pieces, and stay focused on what’s important by automating away mundane, trivial tasks. Adopt these techniques and you’ll be able to avoid productivity traps and start building React components at a stunning pace!

Customer Reviews

Test-Driven React is a great hands-on introduction to the latest technologies in
front-end development. Even if you have little experience with React and frontend
testing, the detailed examples in this book will guide you every step of the
way to creating working and tested code.

- Ludovico Fischer

Author of "React for Real"

This book is an amazing timesaver for those entering the world of modern Java-
Script. It’s full of tips for the whole React development ecosystem, including VS
Code, Jest, Babel, ESLint, Webpack, Enzyme, and many other tools. I’m sure that
most developers, even those already quite experienced, should find it more than

- Stefan Turalski

FX Software Developer, BNP Paribas

Twenty-first century web app development (especially in React) can easily become
a morass of npm dependencies, copy-pasted Stack Overflow code, and general
kludginess. Fortunately, there is hope, in the shape of test-driven development
(TDD): write a failing test; make it pass; refactor; repeat. Trevor Burnham’s Test-
Driven React will help lead you back from the brink so you can make web development
pleasurable again.

- Richard Murnane

Software Developer, 3P Learning

JavaScript development can sometimes feel overwhelming: so many different
frameworks, so much configuration. You don’t always know where to start. Test-
Driven React cuts straight through all the confusion, and quickly gets you on the
path to shoring up your React apps with solid test coverage. And the techniques
Trevor provides extend even beyond React. I’m certain I’ll be referring to this book
for all my future JavaScript projects.

- Darin Wilson

Principal Software Engineer, Infinite Red

Test-Driven React will be a most trusted companion for anyone eager for professional
and battle-tested practices applied to the React ecosystem. If you want to
learn how to develop robust, safe and maintainable applications, this is the way
to go.

- Peter Perlepes

Lead Front-Line Engineer, Welcome Pickups

This is an incredibly comprehensive guide to improving the testing and development
workflows of React developers at any experience level. Whether you’re looking
to test a React component for the first time or rework your testing workflow after
years in the industry, Test Driven React’s engaging and interactive lessons will
fundamentally change how you think about JavaScript testing.

- Adam Markon

Software Engineer, HubSpot

In an era when big structures are built with small components, unit tests and
TDD are a must for every React developer.

- Tim Givois

Senior Engineer, Wizeline

See All Reviews

Choose Your Format(s)

  • $19.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

You’ll need a working knowledge of JavaScript and a computer running macOS, Windows, or Linux.

Contents & Extracts

  • Introduction
    • What’s in This Book
    • What’s Not in This Book
    • How to Read the Code Examples
    • Online Resources
    • Mantra: Code with Joy
  • Test-Driven Development with Jest
    • Introducing Jest excerpt
    • The Tao of Test-Driven Development
    • Mantra: Red, Green, Repeat
    • Example Fizz Buzz Solution
  • Integrated Tooling with VS Code
    • Editing with VS Code
    • Checking Code Quality with ESLint
    • Beautifying Code with Prettier
    • Real-Time Testing with Wallaby
    • Mantra: Live in the Code
    • Example Palindrome Finder Solution
  • Testing React with Enzyme excerpt
    • Starting a React Project
    • Testing Simple Components with Enzyme
    • Adding a Jest Setup File
    • Testing Nested Markup
    • Testing Stateful Components
    • Mantra: Test One Piece at a Time
  • Styling in JavaScript with Styled-Components excerpt
    • Packaging an App with webpack
    • Getting Started with Styled-Components
    • Testing Styled Components
    • Mantra: Actively Seek Feedback
  • Refactoring with Higher-Order Components
    • Making Higher-Order Components
    • The Controllable Pattern
    • Stacking Higher-Order Components
    • Inspecting Components with React Devtools
    • Mantra: Keep the Unit Small
  • Continuous Integration and Collaboration
    • Setting Up Travis CI
    • Git Hooks with Husky
    • Adding Docs with Storybook
    • Mantra: Actively Automate


Trevor Burnham is an engineer at HubSpot in Cambridge, MA. His previous books include CoffeeScript and Async JavaScript, both published by PragProg. You can follow him on Twitter as @trevorburnham.