Package Spotlight: Sinon

Package Spotlight: Sinon

Testing is only as good as the test writers ability to spying, stubbing, and mocking the code they are testing.

For reference for those who don’t work with unit and integration tests I’d like to quickly go over some definitions.

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.

Sinon is clean, small, and powerful. It’s a tool that any test writer cannot be without. We use Sinon heavily as part of our JavaScript testing strategy.

Package Name: Sinon.JS
Website: https://sinonjs.org/

Feature Announcements
TRYTN

Customer Cart Widget

We recently released some new functionality specific for those tour operators that use the embedded booking experience. We’ve heard feedback that customers find it confusing

Read More »
someone ideating on a white board with comps
Release Notes
TRYTN

May 2021 Release Notes

Is it already the end of May?! We’ve been heads-down squashing over 60 bugs while focusing on high-touch first experiences like registration, login, and account

Read More »

Request a Demonstration