Skip to content

Implement the Ability to Revert the Mocking of Modules #7376

@constraintAutomaton

Description

@constraintAutomaton

What is the problem this feature would solve?

In the current Bun test package, it is possible to mock a whole modules using the function mock.module (I don't think this feature is documented...). But it doesn't seem like it is possible to revert to the original implementation. I think in multiple situations this feature is needed and popular frameworks like Jest, who seem to be an inspiration for the test package of Bun, implement it.

What is the feature you are proposing to solve the problem?

A mock.revertAllMock function and an object return from the mock.module function with a method to revert to the specific module to its original implementation.

What alternatives have you considered?

I don't have an other idea.

Metadata

Metadata

Assignees

Labels

bun:testSomething related to the `bun test` runnerenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions