What are unit testing tools used when we code typescript.

What is the best and most efficient?

closed as too broad by IAmMilinPatel, Niels van Reijmersdal, ECiurleo, bish, Kate Paulk Jan 8 '16 at 13:18



In my search to unit-test in TypeScript I found The Intern most interesting as you can also write the tests in actual TypeScript instead of JavaScript. I most say that I haven't really used it in production, just some small experiments as proof of concept.

Here is an article explaining how to use it combined with TypeScript: https://www.sitepen.com/blog/2015/03/24/testing-typescript-with-intern/

Looks pretty promising when you are using TypeScript and you are looking for a unit-testing setup that supports source maps.

Example test:

import registerSuite = require('intern!object');
import assert = require('intern/chai!assert');
// Assume that we now have a version of our model in TypeScript:
import SimpleTodoModel = require('todo/model/SimpleTodoModel');

    name: 'SimpleTodoModel',
    // Assume we have a promises interface defined
    'default data'() {
        var emptyModel = new SimpleTodoModel(),
            id:string = emptyModel.get('id'),
            length:number = emptyModel.get('todos').length,
            incomplete:number = emptyModel.get('incomplete'),
            complete:number = emptyModel.get('complete');
        assert.strictEqual(id, 'todos-dojo',
                    'Id should default to "todos-dojo"');
        assert.strictEqual(length, 0,
                    'Todos array should default to an empty array.');
        assert.strictEqual(incomplete, 0,
                    'Incomplete count should default to 0.');
        assert.strictEqual(complete, 0,
                    'Incomplete count should default to 0.');
