Skip to content

Add more documentation on auto-mocking #6812

@Morikko

Description

@Morikko

🚀 Feature Proposal

Add more documentation on what auto-mocking do, especially for jest.genMockFromModule.
The purpose is to say how each type is transformed by Jest.

Motivation

You have to test the mocked object to know how each type is transformed by jest.

Example

  • Function -> Create a mock function that returns undefined
  • Async Function -> Create a mock function (synchronous) that returns undefined
  • Object -> Do a deep copy of the object (keep the interface) and mock the sub elements
  • Class -> Keep the interface and the type but all the functions are mocked
  • Array -> Empty array
  • String -> copy
  • Number -> copy
  • Date -> undefined

I could do the PR, however I would gladly appreciate a review of those assumptions.
Also, if some types are missing, let me know.

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