Jump to ratings and reviews
Rate this book

Test-Driven React

Rate this book
You work in a 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! React has revolutionized web development by abstracting away the details of DOM manipulation. That conceptual elegance has opened the door to a new generation of web clear, expressive, and lightning-fast. That makes React a perfect fit for test-driven development (TDD), a methodology in which tests are a blueprint instead of an afterthought. Each chapter will present new projects to challenge you and new tools to help you. Write fast, portable tests with Jest. Keep your code tidy with ESLint and Prettier. Perform every task you need from a single window with VS Code. See your test output directly in your code with Wallaby. Use the JavaScript features of the future with Babel. Make assertions about React component behavior with Enzyme. And style components in a testable way with styled-components. By understanding every piece of your project's stack, you'll feel more confident and able to focus on what writing reliable and maintainable code. Discover a more joyful React development experience. Let your tests lead the way! What You You'll need a working knowledge of JavaScript and a computer running macOS, Windows, or Linux.

190 pages, Paperback

Published June 5, 2019

6 people are currently reading
44 people want to read

About the author

Trevor Burnham

6 books6 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
5 (13%)
4 stars
6 (16%)
3 stars
18 (50%)
2 stars
6 (16%)
1 star
1 (2%)
Displaying 1 - 13 of 13 reviews
Profile Image for Jeffrey.
293 reviews19 followers
September 17, 2020
Descent book, but not what I expected. Do no react developers start with create-react-app? Since that’s all I’ve ever used/learned starting a project from absolute scratch always seems so overwhelming and to boot custom starts always use totally different libraries (e.g. Enzyme vs testing-library/react).
174 reviews4 followers
April 24, 2020
This was not what I was looking for (or expecting from Prag Prog), so my two stars may be unfairly harsh. Okay, I'm giving it three stars.

This is an extremely detailed walkthrough of using maybe a dozen separate tools in concert to implement testing practices. The examples are cleanly written, detailed, and well annotated noting changes in each step. There is some small discussion of the conceptual choices of each tool along the way. There is a lot of finagling details that is probably very precisely stuck in time, a year to three months before the book went to press somewhere in 2019.

Better than many books, it doesn't *just* throw in five different tools to accomplish the simplest example without explanation.

But unlike The Cucumber Book from Prag Prog, this book is completely focused on details and individual tools with concepts being relatively secondary.

The coverage of many different tools does go into a little detail with customization in most cases, probably very helpful if you're following along with activities precisely, but it doesn't go deep into most individual tools and what and why might be customized or overridden.
Profile Image for Daniel Godfrey.
144 reviews16 followers
January 1, 2022
Using React in VS Code for a new project. Since I'm new to both, this book which features both stood out to me. Before reading, I had:
* Several years of software development in object-oriented languages (especially Java)
* Some experience with Test-Driven Development
* Working knowledge of Javascript and React from several months of trying them out

After two very strong chapters on getting set up with the Jest testing framework and VS Code, the book motivates other techniques with a project of an image carousel. Some additional topics this book covers:
* Refactors and design patterns in React development and testing
* CSS-in-JS, a technique that facilitates unit-testing how your website looks
* Automated builds with Travis
* Interactive documentation with Storybook
* Gitmoji, whose use of emoji for commit types (e.g. memo pad for documentation) makes it easier to skim git history logs

In the introduction the book says it's for newcomers like me to React but assumes knowledge of JavaScript. And that matches what I found too. The book is good at explaining what each library or tool is, and excels at informing its readers on how to set things up. The VS Code workflow (plus hotkeys, extensions like Prettier autoformatter, etc.) described here is highly streamlined, boosting productivity by writing code very quickly!

My main concern with the book is how it will age. The author took great care to list the versions of every library used, so I think the Image Carousel project will stand the test of time. The discrepancies from the text that I ran into when going through this in late 2021 (a few years after the book's publication), were usually "around the edges." This usually fell into minor things like how GUIs (e.g., for VS Code or Travis) were laid out.

One less minor example was the interactive documentation library Storybook, which I was especially keen on trying out and thrilled to use... although I had to go a slightly different route than the book describes. Ultimately I used a current (for now) version of Storybook -- 6.4.9 instead of the 4.1.11 in the text -- which had Storybook Controls, which can be used instead of @storybook/action-knobs. Just knowing techniques like these are out there is exciting to me, although using them in the future may require additional research as they evolve over time. On a related note, I didn't have issues with the carousel's libraries, even though I wasn't using the exact versions shown in the book -- and the author also tells you how to do that if you need to.

Even with my limited experience in React and JavaScript, I was able to quickly come up with solutions on my own using TDD early in the book. Around chapter 5, the book's solutions started to use more advanced techniques and procedures I'm less familiar with. One example is Component lifecycle. Throughout the book, the author keeps things focused by pointing readers to many external links where they can learn more; component lifecycle had links. In instances like these, though, I opted instead to learn by copying the book's solutions and running them. (I hope to revisit this book and try out more of its links after learning more about React and especially JavaScript.)

On the whole, I thought this was a very good resource for getting set up and spun up on developing in React, with nifty tips on how to make your dev/test feedback loop as tight as possible.
Profile Image for Geoff Lanotte.
164 reviews6 followers
September 2, 2019
This was a very well done book, it was extremely accessible and took you through a good TDD workflow and how to do that with using react and the current tools. Some of the things I liked was that every install was with specific versions of libraries so that you ran into very few issues with library changes. The steps were very well explained and the comments were very helpful. The author has a very solid and helpful didactic method and seemed to anticipate my questions as I was working through the book.

I have two small issues with the book, not serious ones but things I think could have been slightly improved. First, there was a real focus on very specific tooling which I fear might date the book prematurely, which will be a loss. Second, there was a good deal of hand-holding throughout the book and very little left as an exercise for the reader. That is more of a preference, but I really like it when there is work for me to do and think about, it helps drive many of the concepts home.

I would recommend this to anyone looking to improve there react game. I knew very little going in and was able to complete it without a problem. I don't think I would recommend this as a general-purpose TDD book though.
Profile Image for Stefano Zanella.
59 reviews2 followers
May 4, 2021
A little bit outdated already unfortunately. Also, the title is a bit misleading in my opinion. Something like: bootstrap React applications with tests and automation (or a marketing-friendly version of the concept) would describe better what this book is about.
Personally I was expecting more a book centered around designing React applications using TDD and higher level design patterns for React components and the interaction between them.
But at the same time I appreciated the primer on a lot of accessory tools like ESlint, Prettier and Husky.
Profile Image for Sina.
41 reviews8 followers
Read
November 27, 2019
Good book overall! it represents its ideas by a real world example. However, it somehow talks about a few other things not related to TDD approach which I guess they are kinda boilerplate ones that you can simply skip them!

But the point is easy to get and follow. It could be a good starting point for testing react components, both for TDD approach and for when you are trying to write unit tests.
6 reviews10 followers
July 24, 2024
Not a bad book! It helps to learn about why and what to install in order to create a testing environment. I expected more testing examples and guidance on how to write better tests.

And I think the second edition is not completely published, so this is a review for all 6 chapters that have been published so far.
Profile Image for Adam Wan.
17 reviews3 followers
December 4, 2024
Disappointed.

This book spends most of the time on toolings and configuration.
Those information can be found on web easily.

I think the values of Test-Driven Development on Frontend is the way to test, what to test and how to test properly - so that it really saves time, provides confidence and protect the codebase.

None of the points can be addressed in this book.
Profile Image for Gustavo Saiani.
14 reviews9 followers
Read
December 1, 2019
As of December 2019, this book is outdated.

React Hooks have largely superseded Higher Order Components.
React Testing Library may be gaining significant ground over Enzyme.

Still I thought it was a worthwhile read.

The finishing sections are nice as they introduce Husky and Storybook.
309 reviews6 followers
October 25, 2021
Very useful, but a bit too prescriptive. If you do read it (and I do recommend it!), immediately do a project on your own following the core react documentation, and referring to this book as little as possible, to make sure you remember the things you go through in the book.
Profile Image for Torben Koch.
27 reviews5 followers
December 14, 2021
Yes, it might be a bit outdated there and there (it is the JavaScript world, after all), and it may be a bit mis-titled. The book is about test-driven React, of course, but it is more about the tool chain that makes test-driven React, in JavaScript, tolerable, possibly even a joy. Again, Enzyme might not be the newest and shiniest, but as developers we can see the pattern.

The chapter about Visual Code integration is worth it all. A bucketful of tips and tricks even experiend (I guess) React-developers can learn from.

It is a quick read, so your time is not wasted!
Profile Image for Justin.
199 reviews44 followers
September 27, 2020
Some useful information, code along, deep in the woods, vastly out of date information, so code doesn't work
Profile Image for James Tharpe.
96 reviews5 followers
December 29, 2020
This is basically a very long blog post, not really book quality and definitely not what I'd consider PragProg material.
Displaying 1 - 13 of 13 reviews

Can't find what you're looking for?

Get help and learn more about the design.