Posts

Redux Containers Unit Testing in React with TypeScript Projects

Purpose: The objective of this document is to describe guidance, recommendations, and practices for applying developer test for Redux containers used in React Project and Typescript. Prerequisites: This article mainly targets people with the knowledge of the followings: -          React -          Redux -          TypeScript -          NodeJS -          Unit testing with Jest Redux Containers unit test: Container mainly responsible for connecting and updating the props values with the new changes in the state by implementing “ mapStateToProps ” also responsible for connecting the dispatches to the page functions by “ mapDispatchToProps ”. Check the following container Example: import  {  connect ,  Dispatch  }  from   ...

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 ...