jstestadapter is a JavaScript test adapter extension for Visual Studio Test Platform. jstest 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 --TestAdapterPath:./node_modules/jstestadapter/ path/to/test.1.js path/to/test.2.js
# Testing with Mocha
path/to/vstest.console.exe --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 --TestAdapterPath:./node_modules/jstestadapter/ path/to/package.json -- JSTest.TestFramework=Jest
Option | Usage | Default |
---|---|---|
TestFramework | One of the following test frameworks for execution: Jasmine/Mocha/Jest | Jasmine |
RunInDomain | Run JavaScript tests in a node Domain. Note: If set to false the test must complete all execution before returning control. i.e. all callbacks such as setTimeout must be completed before the test completes execution. | true |
DebugLogs | Enable debug logs for JavaScript test runner | false |
DebugFilePath | Path for diagnostic logs | "" |
TestFrameworkConfigJson | Override test framework configurations (Specific to the testframework) in json format | {} |
NodeModulesPath | Custom path to node_modules | "" |
vstest.console.exe --Isolation --TestAdapterPath:<path> <files> -- JSTest.DebugLogs=true JSTest.TestFramework=mocha
vstest.console.exe --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>
For uploading test result attachments along with tests checkout karanjitsingh/jstestcontext
# Build binaries and javascript to `./artifacts/Debug/net451/` along with the package tarball in `./artifacts/Debug`
.\scripts\build.ps1
Option | Value | Description | Default |
---|---|---|---|
-clean | Clean built output | false | |
-nolint | Build without tslint pass | false | |
-configuration | Debug, Release | Build configuration | Debug |
-target | net451, netstandard1.4 | Platform for building managed code | net451 |
# Self dogfooding jstest javascript tests
.\test.ps1 -vstest \path\to\vstest.console.exe
Option | Value | Description | Default |
---|---|---|---|
-runonly | Run tests without building | false | |
-parallel | Enable run tests in parallel for vstest | false | |
-discover | Enable --listtests option in vstest | false | |
-configuration | Debug, Release | Build configuration | Debug |
-log | \path\to\log | Will enable vstest diagnostic logs | - |
-test | "test filter" | Test filter | - |
-vstest | \path\to\custom\vstest.console.exe | Path to vstest.console.exe | D:\vstest\artifacts\Debug\net451\win7-x64\vstest.console.exe |