Unit testing using Typescript, Mocha, Chai, Sinon, and Karma
In this post, Premier Developer consultant Wael Kdouh outlines how to set up a unit testing project using Typescript, Mocha, Chai, Sinon and Karma.
The NPM Packages
Run npm install command which will restore all the dependencies included in the package.json file below. Note that we are using the new feature under Typescript 2 which is the @types namespace.
The TypeScript Configuration File
The Karma Configuration File
Start by setting up the required frameworks and the file dependencies.
Next inform Karma to use the typescript preprocessor to transpile the .ts files to .js files on the fly
The Gulp Configuration File