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
12 min read3 hours ago
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 thisarticle,e 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.

In this communication, we can see what types of tests we can perform. We can think about e2e tests, the slowest ones, but with React we can use JSDOM and run the test many times at the unit test level, much faster. However, it’s not…

Particularly slow if we need to run e2e tests and need to load the entire environment. But with JSDOM, despite being fast too, it often also takes considerable time.

--

--

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.

No responses yet