What is the difference between Jest Mock features and Sinon spies

I mock the feature with Jest, and the documentation says that they are really β€œspies.” I also saw the use of spyware in SinonJS, but I could not find a clear difference between the two. If they serve the same purpose, is there any reason to choose one over the other?

Jest mock functions

Sinonjs

+5
source share
1 answer

The basic behavior of both is the same; these are functions that can remember their calls. So for both of you, you can understand how often they were called with the arguments of the witch. Sinon has a much wider API for what you can check on spyware, and it has an API for replacing functions in objects with spyware.

+11
source

Source: https://habr.com/ru/post/1264316/


All Articles