2.0.1 • Published 7 months ago

jstestadapter2 v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Build Status npm version npm version

jstestadapter

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.

This fork addresses a path related bug when using jstestadapter with jest V29. There is no planed maintenance beyond this one bug fix.

Install

npm install --save-dev jstestadapter

Usage

# 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

RunSettings Configuration

OptionUsageDefault
TestFrameworkOne of the following test frameworks for execution: Jasmine/Mocha/JestJasmine
RunInDomainRun 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
DebugLogsEnable debug logs for JavaScript test runnerfalse
DebugFilePathPath for diagnostic logs""
TestFrameworkConfigJsonOverride test framework configurations (Specific to the testframework) in json format{}
NodeModulesPathCustom path to node_modules""

RunSettings can be provided through the the vstest cli itself

vstest.console.exe --Isolation --TestAdapterPath:<path> <files> -- JSTest.DebugLogs=true JSTest.TestFramework=mocha

Using RunSettings xml defined for vstest

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>

Test result attachment support

For uploading test result attachments along with tests checkout karanjitsingh/jstestcontext

Building from source

# Build binaries and javascript to `./artifacts/Debug/net451/` along with the package tarball in `./artifacts/Debug`
.\scripts\build.ps1

Build Options

OptionValueDescriptionDefault
-cleanClean built outputfalse
-nolintBuild without tslint passfalse
-configurationDebug, ReleaseBuild configurationDebug
-targetnet451, netstandard1.4Platform for building managed codenet451

Running Tests

# Self dogfooding jstest javascript tests
.\test.ps1 -vstest \path\to\vstest.console.exe

Test run options

OptionValueDescriptionDefault
-runonlyRun tests without buildingfalse
-parallelEnable run tests in parallel for vstestfalse
-discoverEnable --listtests option in vstestfalse
-configurationDebug, ReleaseBuild configurationDebug
-log\path\to\logWill enable vstest diagnostic logs-
-test"test filter"Test filter-
-vstest\path\to\custom\vstest.console.exePath to vstest.console.exeD:\vstest\artifacts\Debug\net451\win7-x64\vstest.console.exe

Tested with framework versions

npm (tag) npm (tag) npm (tag)

Used and loved by

Azure Pipelines

2.0.1

7 months ago

2.0.0

7 months ago