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.
A very simple demo is available here: Demo
-
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
-
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
Download and install from the Visual Studio Gallery here: Karma Test Adapter
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",
"config": {
"browsers": [
"PhantomJS"
]
}
}
There are two properties:
-
karmaConfigFile
Use this if you want to use a karma configuration file not namedkarma.conf.js
. -
config
This property overwrites any configurations from the karma configuration file.
At the moment the adapter only works properly with Jasmine tests. It should be relatively easy to add other frameworks. Pull requests are welcome.