Visual Studio Unit Tests with NodeJS and TypeScript

Visual Studio has the magic window “Test Explorer” which discovers unit tests on your application and list them. It shows information about the tests.

unittestnodejs

It can be used on a NodeJS project.

To do that, select the file which contains the tests on the solution explorer, click to view the file properties.

testframework

Enter a test framework (ExportRunner for example). If you are using ExportRunner then your tests will look like:

export function Test1()
{
    throw "fail";
}

export function Test2() { }
export function Test3() { }
export function Test4() { }
export function Test5() { }

The test framework is automatically set if you create the file in Visual Studio selecting the right file type. You can also use other test frameworks, like Mocha.

Watch this video to see a complete example:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s