The Jest Handbook
- Gain a deep understanding of the options available to the Jest CLI and how to use different views to write and debug tests more effectively.
- Use and contrast 2 approaches to testing backend applications with Jest as well as illustrate synchronous and asynchronous testing patterns.
- Employ advanced Jest partial matchers to write tests with high specificity and reduce toil when updating application code.
- Leverage Jest’s built-in coverage tool to set minimum coverage thresholds, find parts of the code that aren’t tested and how to disable it in specific cases.
Jest is a batteries-included framework with best-practices, a test runner, CLI, assertion library, stubbing library, module mocking library and coverage built-in.
- snapshots: a simple system to keep track of changes within a system
- isolated: tests are isolated from each other, this means fewer issues with tests modifying shared resources like global objects or module mocks.
- familiar/“great” API: Jest supports helper methods to write your tests with, including
test. Tests are Promise-aware (and therefore support
asyncfunctions as tests), for example if a Promise returned from a test rejects or an async test throws, the test will fail with the corresponding error.
Jest is a very powerful framework for those who know how to wield it.
Using the Jest Handbook
The Jest Handbook is designed as a reference on how to use Jest in different use cases.
Beyond the Jest documentation and some titles on “Testing React/Vue.js with Jest”, there are few pieces of work similar to the Jest Handbook.
It’s recommended that you give The Jest Handbook mainly to give you an overview of what’s possible with Jest. This solves the “I didn’t even think of doing that” problem.
All the examples in the Jest Handbook are available at github.com/HugoDF/jest-handbook-examples.