dam0 / KarmaTestAdapter

A Visual Studio test explorer adapter for Karma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Karma Test Adapter

A Visual Studio test explorer adapter for Karma

This extension integrates Karma - Spectacular Test Runner for Javascript with the test explorer in Visual Studio 2013.

Demo

See a demo video

A very simple demo is available here: Demo

Features

  • Scans the files from the karma configuration to discover tests.

  • Registers the file and position of each test, so that the test explorer in Visual Studio can link to the source code for the test.

  • Source maps in test files are used to find the position of tests. So if a test is written in Typescript and the compiled javascript file contains a source map the test explorer will link to the typescript file.

  • Can run selected tests

Prerequisites

  • Install NodeJS

  • Install Karma in your project: npm install karma --save-dev

  • Install the Karma Visual Studio Reporter in your project (at least version 0.5.3): npm install karma-vs-reporter --save-dev

Installation

Download and install from the Visual Studio Gallery here: Karma Test Adapter

Configuration

Set up Karma normally (as described here: Installation and here: Configuration).

Install this extension.

Start testing!

If you want Visual Studio to work differently from how Karma is configured (if you f.ex. only want to run PhantomJS from VS), you can create a JSON settings file called karma-vs-reporter.json. F.ex.:

{
    "karmaConfigFile": "karma.conf.test.js",
    "LogToFile": true,
    "config": {
        "browsers": [
            "PhantomJS"
        ]
    }
}

There are two properties:

  • karmaConfigFile Use this if you want to use a karma configuration file not named karma.conf.js.

  • config This property overwrites any configurations from the karma configuration file.

Caveats

At the moment the adapter only works properly with Jasmine tests. It should be relatively easy to add other frameworks. Pull requests are welcome.

About

A Visual Studio test explorer adapter for Karma

License:MIT License


Languages

Language:C# 56.7%Language:JavaScript 23.3%Language:TypeScript 19.7%Language:Shell 0.4%