luhmann/hired

View on GitHub
doc/architecture/decisions/0005-jest.md

Summary

Maintainability
Test Coverage
# 5. Jest

Date: 04/04/2017

## Status

Accepted

## Context

* There is an abundance of testing frameworks within the javascript world
* Jest is one of the more modern ones, it is developed by Facebook, it offers a great experience due to a batteries included approach
* Jest offers snapshot testing
* Jest configuration comes for free when you bootstrap an app with `create-react-app`
* It already offers mechanisms for expectations and mocks/spies, so we do not need additional libraries
* Jest only runs in Node or JsDom. Testing in "real" browsers is not possible. This offers less reliability but tests that run faster.

## Decision

We are using Jest as the above mentioned benefits outweigh the negative of not being able to test in a real browser,
which brings its own difficulties concerning speed and stability for the whole test setup anyway. We will adress the
potential issues of not having tested the javascript code in real browsers in other ways

## Consequences

* Use snapshot testing for simple assertions of structure or output, but **do** take care that inspect the snapshots
if the really hold the expected result. Also be aware that if you rename a test, you will generate a new snapshot,
which is not diffed against the old one.
* We will setup an error-reporting mechanism which sends all javascript runtime-errors to an error-logging service,
so we quickly notice if we should have shipped code that passes our tests but does not run in any one browser in the wild.