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/

diagram
Blog
Virginia

Reimagining Company Logos

A company’s logo is important, whether you’re starting a business or refreshing your look. Having a timeless logo allows you to capture your customers’ attention and become memorable.

Read More »
Blog
Virginia

Responding to Reviews

Could making your company shine be as easy as responding to customer reviews? In this article you will learn why simply replying to customers’ reviews is so important in making each customer feel valued, appreciated and ultimately validated.

Read More »
a person standing on top of a mountain
Blog
Virginia

The Rise of Solo Travel

Over the past few years, solo trips have become a growing trend in the tourism industry. With more and more people deciding to travel alone, one factor has endured — tourists want to have fun!

Read More »

Request a Demonstration