BuiltByCactus

Engineering Handbook

Testing

As with PHP, testing our JavaScript code is important to make sure it’s free of bugs and that we don’t introduce any regressions when we come to update or refactor something.

Jest

Jest is a great JavaScript testing framework that works with any library. This is generally our go-to as it allows us to write readable tests with very little config.

React Testing Library

The React Testing Library is built on top of the DOM Testing Library and adds APIs for working with React components.

This is a great library that we should strive to use for all React projects as it forces you to test the outcome of an interaction and not to test implementation details. Its primary guiding principle is:

The more your tests resemble the way your software is used, the more confidence they can give you.

Which makes a lot of sense. So let’s try and stick to it!

Resources