Open alexey-yarmosh opened 1 year ago
As I understand there is no way to explicitly .reset() the mock too. So writing test seems blocked right now.
Regarding the above, you can call mockClear
or mockReset
on the mock. The behaviour is the same as Jest (documentation for Jest).
Working, thanks!
What is the expected behavior?
random
mock resets between tests and they are passing.
I don't think this is a bug. Jest doesn't clear or reset mocks before every test by default and since Bun's test runner is heavily inspired by Jest I wouldn't expect it to do so either. However Jest can be configured to do so (source 1, source 2), while it doesn't seem possible in Bun right now. So I think this should be labelled a feature request and not a bug.
Documentation says that, so I though that is the only available option:
Mocks are automatically reset between tests.
But I agree with @winghouchan, most likely that should work like currently implemented, without implicit resets. So doc update is fine, also adding a reset example will be nice.
Mocks are automatically reset between tests.
Just ran into this issue myself. Docs should be updated, users are currently being misled.
Happened the same to me. Please, update the docs.
What version of Bun is running?
1.0.1+31aec4ebe325982fc0ef27498984b0ad9969162b
What platform is your computer?
Darwin 22.4.0 x86_64 i386
What steps can reproduce the bug?
What is the expected behavior?
random
mock resets between tests and they are passing.What do you see instead?
Additional information
As I understand there is no way to explicitly .reset() the mock too. So writing test seems blocked right now.