TypeScript Alsatian


Example

Alsatian is a unit testing framework written in TypeScript. It allows for usage of Test Cases, and outputs TAP-compliant markup.

To use it, install it from npm:

npm install alsatian --save-dev

Then set up a test file:

import { Expect, Test, TestCase } from "alsatian";
import { SomeModule } from "../src/some-module";    

export SomeModuleTests {

    @Test()
    public statusShouldBeTrueByDefault() {
        let instance = new SomeModule();
        
        Expect(instance.status).toBe(true);
    }
    
    @Test("Name should be null by default")
    public nameShouldBeNullByDefault() {
        let instance = new SomeModule();
        
        Expect(instance.name).toBe(null);
    }
    
    @TestCase("first name")
    @TestCase("apples")
    public shouldSetNameCorrectly(name: string) {
        let instance = new SomeModule();
        
        instance.setName(name);
        
        Expect(instance.name).toBe(name);
    }
    
}

For a full documentation, see alsatian's GitHub repo.