How React Testing Library Can Improve Your Mental Health [Part 1]

How React Testing Library Can Improve Your Mental Health [Part 1]

I know one person who likes writing tests, and it is not me! I like adding code-coverage to my code and you'll see why.

I know one person who likes writing tests, and it is not me! I like adding code-coverage to my code and you'll see why.

My name is Maciej, I'm a software engineer, and you can find how to pronounce my name here: sayoname.com/me/maciej

Omitting tests is OK only if the project is your small to-do app. 

Not having tests will become a problem sooner or later. Now you might deploy features quickly. But the day when you cannot release for weeks because of cropping bugs here and there will come and this will happen...

If the project grows it WILL become a problem! Imagine - you start getting users, making money, hiring devs, there are so many feature going on that you will not be able to keep all those dependencies in your head.

I worked in a place once which had a pretty big code project with no tests at all. The repo was massive, thousands of customers used it every day and they paid millions. But customers were paying and they wanted new features. Some were simple, like changing text and adding a button here and there. Some were more complex like providing integration with external software.

One day we got our Product Owner (PO) who specified this new requirement. We needed a few new reports for customers, which were basically a couple of new tables. What started as a small task which we scoped around 4-weeks until production. Turned out to be a 4-month struggle with tens if not hundreds of bugs raised by QA.

Why was that? It wasn’t the technology used, it wasn’t the developers ;) and it wasn’t the complexity of the project. It was the lack of tests!

There were three of us working on those features, and due to no tests, we didn't know if our changes break someone else's code!

Another problem was that those bugs were usually found after a couple of days of full manual regression testing. After a bug was raised we had to pick bug fixes as a priority and switch context. And then investigate, trying to remember why I wrote this rubbish code, fix it, create a PR, get it approved, and then release (obviously manually, because what did you expect from a no tests codebase).

This massive gig made the business realize we cannot do it anymore and a decision has been made to rewrite the whole app! It took almost 18 months and obviously, no new features were added in the meantime.

You get now why tests are important. You don't? Close the page, you'll never get it! Get back to adding functionality and stop wasting your precious time even reading about tests!

react react-testing-library reactjs testing

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Interaction Testing with React Testing Library

Testing is complicated. I’ve certainly never been good at it. For the longest time, I’ve only been focused on basic function input-output unit tests. Why? Because they were easy — you didn’t need to render HTML, you didn’t need to query DOM elements, you didn’t need to interact with said DOM elements. But of course, React component testing is a necessity for any mature codebase. And it finally came time for me to sit down and figure it out. A window into React component testing. Interaction Testing with React Testing Library

Test Driven Development (TDD) with React Testing Library & Mock Service Worker

Let’s step up our testing game with two useful libraries that lend themselves excellently to a TDD approach.

How React Testing Library Can Improve Your Mental Health [Part 2]

How React Testing Library Can Improve Your Mental Health Part 2

React Testing Library: The Modern Way to Test React Components

Unit testing, and in our case, testing components, is a key element of any scalable and maintainable project. That truism is even more obvious now in the age of independent and shareable components. When sharing components between projects, testing serves as a way to both validate that a component behaves as expected and that it is independent and reusable (otherwise it would show to be very difficult to test).