Showcase unit testing of TypeScript 2 project with jQuery and RequireJS through Karma and Jasmine. This project is an example on how to setup Unit Testing in a TypeScript 2 project using Karma as test runner and Jasmine as test framework. The project code itself tries to mimic a simplistic real-life example. It does that by using RequireJS as module loader and including jQuery as JavaScript library.
Clone this project and follow these steps to get it up and running on your own computer.
- Install NodeJS and NPM for your system
- Install TypeScript globally:
npm install -g typescript
- Install Node project dependecies:
npm install
- Install Gulp globally:
npm install -g gulp
You can use either gulp test
or it's alias npm test
to run the karma test runner.
You can run gulp
to build the project. Eventually when the build completes you'll find all the necessary files in the dist/
folder.
It's possible to serve the files in this folder as a static website. You can use a simple webserver like http-server
for testing purposes.
For easier debugging you could also serve the build/
folder as static website. The uncompressed JavaScripts will be served when you load the index.html from that location.