A collection of small test examples I wrote while learning Jest — covering matchers, mock functions, async testing, setup/teardown, and more.
This repository is a sandbox for learning and experimenting with Jest.
It contains examples of:
-
Writing simple unit tests
-
Using different Jest matchers
-
Working with mock functions
-
Handling asynchronous code in tests
-
Using setup and teardown methods (
beforeEach,afterEach, etc.) -
Basic matchers (
toBe,toEqual,toContain, etc.) -
Mock functions and spies
-
Async code testing (
async/await,.resolves/.rejects) -
Setup and teardown hooks
-
Testing exceptions