Skip to content

Documentation: guide for using jest.mock #8543

Closed
@sargalias

Description

@sargalias

🚀 Feature Proposal

A guide on basic mocking with jest using jest.mock. The guide would be on the sidebar after "Timer mocks".

It would explain how to use jest.mock properly, what the different parameters do and provide examples for using them.

Motivation

When I was a beginner I didn't understand how to use jest.mockat all, particularly the second parameter of jest.mock. This was even more fiddly because I use ES6 modules, giving the default export another "gotcha" when used in tests.

As this is quite an essential feature for unit testing I think a guide will be beneficial to many users.

Please let me know your thoughts. If it sounds good I can make a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions