Skip to content

gobengo/alsatian-cli-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alsatian-cli-function

Exports a function to run a provided file using alsatian.

Why?

So you can easily turn each of your alsatian test files into an executable script that doesn't depend on the alsatian CLI. You can just run it with node path/to/your/file.js or ts-node path/to/your/file.ts.

YourTest.ts:

// no globals and typing support out of the box with intellisense
import { Expect, Test, TestFixture } from "alsatian";
import cli from "alsatian-cli-function";

@TestFixture("whatever you'd like to call the fixture")
export class YourTestFixture {
    @TestCase(3, 3, 6)
    @Test("addition tests")
    public addTest(firstNumber: number, secondNumber: number, expectedSum: number) {
        Expect(firstNumber + secondNumber).toBe(expectedSum);
    }
}

if (require.main === module) {
  (async () => {
    await cli(__filename);
  })();
}

Then: ts-node YourTest.ts to run the tests in that file.

Gratitudes

Thank you to jamesadarich and other contributors for working on alsatian.

About

Small module exposing a function that runs alsatian tests in a single file.

Resources

Stars

Watchers

Forks

Packages

No packages published