/jest-mock-examples

Examples of mocks in Jest

Primary LanguageTypeScriptMIT LicenseMIT

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