Posts

Showing posts with the label API

Applying React and Typescript API Calls unit test using Sinon

Purpose: The objective of this document is to describe guidance, recommendations, and practices for applying developer test for API calls using Sinon library for mocking API calls. Prerequisites: This article mainly targets people with the knowledge of the followings: -          React -          TypeScript -          NodeJS -          Unit testing with Jest Overview: Sinon is a standalone and test framework agnostic JavaScript test spies, stubs and mocks. Let’s go through some important methods we can use from Sinon during our unit test. ·      Sandboxes var sandbox = sinon.createSandbox(); Creates a new sandbox object with spies, stubs, and mocks. var sandbox = sinon.createSandbox(config); The  sinon.createSandbox(config)  method is ...