Spies are a way to interject a spy into code that is being tested so you can literally spy on the code. You use these spies to look into the code as it’s working.
Stubs, on the other hand, are a stub of the code that’s being executed but not being tested. An example is you call a function that perhaps executes some code in another module. You don’t want to execute that code but perhaps you want to confirm the code is executed as expected. You can create a stub to simply assert that the code was triggered as expected. Another good use for stubs is to return specific cases to test all aspects of the code.
Lastly there are mocks which are fake items that code relies upon. A common use case for a mock is a server. Perhaps you make a third-party call to an external provider. You mock that call so you don’t actually make that external call in your tests.
Package Name: Sinon.JS