Member-only story

Execute React Tests 100x Faster Without Sacrificing Accuracy

A humble pattern for React that makes testing with react insanely fast

David Rodenas PhD

Prompted and edited by the Author.

In various articles, I have discussed the direct relationship between testing speed and code quality: the faster the testing, the higher the code quality. However, having fast tests isn’t always easy. And often, making tests faster means making them slower first. Well, in this article, I present an adaptation of an old pattern that enormously accelerates tests.

What’s holding us back?

When we’re talking about React components, we’re talking about the outermost layer of the application: the one that communicates with the client. Here, how it communicates with the browser — or with the native part — comes into play and tends to be the slowest part.

And depending on how we need to communicate with the browser, and what to do, we can choose which kind of tests we can implement. We can think about e2e tests, the slowest ones. So, other kinds of tests, like the unit tests are faster, and we can emulate most of the browser behavior required for React when using JSDOM. So, we

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (4)

Write a response

This is a fascinating approach to optimizing React tests by leveraging the Humble Object pattern. It's insightful to see how separating logic from the view can dramatically improve testing speed. Thank you for sharing the information 👍

Very helpful and to the point. Thanks for sharing! 🙏

Innovative adaptation of the Humble Object pattern to React, effectively decoupling logic from UI for enhanced test speed and maintainability.