Project Description
tsUnit is a unit testing framework for TypeScript, written in TypeScript. It allows you to encapsulate your test functions in classes and modules.

tsUnit is a TypeScript unit testing framework that allows you to define your unit tests inside TypeScript classes and modules.

tsUnit has built-in assertion helpers you can use in your test.

You can use the built-in output to display the test results, or take the test results and customise how they are displayed.

Simple

It is so easy, you don't even have to download and unzip anything. It is just one file, written in TypeScript... hit the DOWNLOAD button to get the latest official release, or grab the very latest version (not guaranteed stable) straight from source control:

tsUnit.ts

If you want to use tsUnit in a plain JavaScript app, you can do that too:

tsUnit.js

Questions and Comments

Please start a discussion if you think a feature is missing or doesn't work as expected.

Example

/// <reference path="tsUnit.ts" />
/// <reference path="Calculations.ts" />

class SimpleMathTests extends tsUnit.TestClass {

    private target = new Calculations.SimpleMath();

    addTwoNumbersWith1And2Expect3() {
        var result = this.target.addTwoNumbers(1, 2);

        this.areIdentical(3, result);
    }

    addTwoNumbersWith3And2Expect5() {
        var result = this.target.addTwoNumbers(3, 2);

        this.areIdentical(4, result); // Deliberate error
    }
}

// new instance of tsUnit
var test = new tsUnit.Test();

// add your test class (you can call this multiple times)
test.addTestClass(new CalculationsTests.SimpleMathTests());

// Use the built in results display
test.showResults(document.getElementById('results'), test.run());

Last edited Mar 3, 2013 at 8:17 PM by Sohnee, version 20