JSTestAdapter is a JavaScript test adapter extension for Visual Studio Test Platform. JSTestAdapter with vstest can be used as a command line tool to run tests written in mocha, jasmine or jest.
npm install --save-dev jstestadapter
# Testing with default test framework, Jasmine
path/to/vstest.console.exe --Inisolation --TestAdapterPath:./node_modules/jstestadapter/ path/to/test.1.js path/to/test.2.js
# Testing with Mocha
path/to/vstest.console.exe --Inisolation --TestAdapterPath:./node_modules/jstestadapter/ path/to/test.1.js path/to/test.2.js -- JSTest.TestFramework=Mocha
# Running tests with jest
path/to/vstest.console.exe --Inisolation --TestAdapterPath:./node_modules/jstestadapter/ path/to/package.json -- JSTest.TestFramework=Jest
Due to a current bug in vstest the switch --Inisolation
is required to run JSTestAdapter.
Option | Usage | Default |
---|---|---|
TestFramework | One of the following test frameworks for execution: Jasmine/Mocha/Jest | Jasmine |
DebugLogs | Enable debug logs for JavaScript test runner | false |
TestFrameworkConfigJson | Override test framework configurations (Specific to the testframework) in json format | {} |
vstest.console.exe --Isolation --TestAdapterPath:<path> <files> -- JSTest.DebugLogs=true JSTest.TestFramework=mocha
vstest.console.exe --Isolation --Settings:RunSettings.xml --TestAdapterPath:<path> <files>
With RunSettings.xml:
<RunSettings>
<JSTest>
<TestFramework>mocha</TestFramework>
<TestFrameworkConfigJson>{
"timeout": 60000,
"slow": 30000
}</TestFrameworkConfigJson>
<DebugLogs>true</DebugLogs>
</JSTest>
</RunSettings>