Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

BulbEnergy/jest-mock-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d7e69f5 · Oct 13, 2020

History

14 Commits
Oct 13, 2020
Oct 9, 2019
Oct 10, 2019
Oct 16, 2019
Oct 14, 2019
Oct 9, 2019
Oct 9, 2019
Oct 16, 2019
Oct 9, 2019
Jan 6, 2020
Oct 9, 2019
Oct 10, 2019
Oct 16, 2019
Oct 9, 2019
Jan 6, 2020
Oct 9, 2019
Oct 9, 2019
Dec 30, 2019

Repository files navigation

Jest mock examples

The purpose of this repo is to list examples of different types of mocking in Jest so anyone can use it as a reference.

It uses:

  1. Jest
  2. Typescript
  3. Prettier

If you have other useful examples or comments, please feel free to contribute.

Install: yarn

Run tests: yarn test

There are examples on how to use:

  • jest.mock and jest.unmock
  • jest.MockedFunction and jest.MockedClass
  • jest.spyOn
  • jest.genMockFromModule
  • jest.requireActual
  • mock fetch and other globals