Testing with Mocha, Chai, Enjyme and Sinon
Chai is a BDD/TDD assertion library
Sinon is used for Spies/Stubs/Mocks. It can also fake ajax calls and timers. So basically it allows you solve problems which occur due to external dependencies.
- Spies - offers information about function cals
- Stubs - Which are like spies but completely replace the functions
- Mocks - It replaces the whole object by combining spies and stubs
Adding Mocha, Chai, Enjyme and Sinon to the project
yarn add --dev chai yarn add --dev enzyme yarn add --dev enzyme-adapter-react-16 yarn add --dev mocha yarn add --dev @types/chai yarn add --dev @types/enzyme yarn add --dev @types/enzyme-adapter-react-16 yarn add --dev @types/mocha yarn add --dev chai enzyme enzyme-adapter-react-16 mocha yarn add --dev @types/chai @types/enzyme @types/enzyme-adapter-react-16 @types/mocha