0
votes

Is there some way to add the Node JS Tools for Visual Studio (NTVS) test adapter to a VSTS hosted agent?

The Visual Studio docs on hosted agent mention "Node.js Tools 1.0 for Visual Studio 2015" in the list for the "Hosted" agent, but the "Hosted VS2017" has no mention of any Node.js Tools

So how can you use the test adapter?

1
The NodeJS tool is available as part of vs 2017, do you mean you can't run test on Hosted VS 2017 agent? - starian chen-MSFT
@starain-MSFT Yes, I can't see how to get my Mocha tests to run as part of a VSTS build. After that I want to have the results appear in the dashboard, and if any fail, stop the build - SteveC
Could you run it on a private build agent? - starian chen-MSFT
@starain-MSFT That was my only thought, but I was hoping to avoid the set-up hassle. I was hoping it was a "in the box" feature I was just failing to understand - SteveC
Check my answer, it works fine for me. On the other hand, another issue of yours, you can check it too. - starian chen-MSFT

1 Answers

0
votes

refer to these steps to run test on Hosted VS 2017 agent.

  1. Modify project file (njsproj)

:

<!--<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>-->
    <VSToolsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0</VSToolsPath>
  1. Copy NodeJsTools folder in C:\Program Files (x86)\Microsoft Visual Studio\2017\[Community, professional or enterprise]\Common7\IDE\Extensions\Microsoft to your ntvs folder
  2. Add these files to source control and check in changes
  3. Queue build with Hosted VS 2017 agent.

Build definition steps:

  1. NPM install (Working folder: $(Build.SourcesDirectory)\NodejsConsoleApp1)
  2. Visual Studio Test task (Test assemblies: NodejsConsoleApp1\NodejsConsoleApp1.njsproj; Search folder: $(System.DefaultWorkingDirectory); Test platform version: Visual Studio 2017; Path to Custom test adapters: NodejsConsoleApp1\ntvs