2021年1月20日星期三

Clearing mocks after each test jest

I am learning Jest and I see this clearAllMocks function being used, I then check the docs and the description is simply this :

Clears the mock.calls and mock.instances properties of all mocks. Equivalent to calling .mockClear() on every mocked function.

Returns the jest object for chaining.

It basically says what you could already figure out by reading the function name.. I still can't figure out when should i use this and why is this useful? Could you name an example when this would be good to use?

Thanks in advance.

https://stackoverflow.com/questions/65819500/clearing-mocks-after-each-test-jest January 21, 2021 at 08:16AM

没有评论:

发表评论