Snapshot Testing with Jest and Enzyme

Unit testing in React


What is Jest?

Jest is a popular Node.js unit testing framework, frequently used with React. Like React itself, Jest is used internally by Facebook as a primary development tool. Jest allows for tests to be run in parallel, greatly increasing efficiency.

Why use tests at all?

Even after you complete an app and get everything finally working, this is always the possibility of future modifications introducing new bugs. Unit testing simply makes it easier to guard against this scenario.

How do I install Jest?

Jest is included with React (and React Native). Otherwise, it can be installed using your package manager of choice

npm install --save-dev jest
yarn add --dev jest
[Read More]

As We May Think

Ideas of Vannevar Bush in practice

Referencing your entire knowledge-base

Vannevar Bush in his seminal essay As We May Think

One of my very favorite strategies is prototyping all of my solutions with unit tests, and having all of my solutions locally, because with a simple text search I can easily reference code I have used in the past.

Refer to past work for convenience

Languages like Java can be frustrating Even the most quotidian operations are often difficult to remember. For example, I KNOW I have converted an int array to an integer list in the past, dozens or hundreds of times. Especially with Java, I never expect anything to work exactly as anticipated, so I reference past work, and put it to the test (with unit testing)

How the heck did I do that?

When your past work is indexed, you can instantly scour reams of code to derive solutions from existing content. That’s working smart.