Friday, November 11, 2016

TFS Build vNext : Running your JavaScript unit tests as part of your build process

Thanks to the Chutzpah test adapter, you can run your QUnit, Jasmine or Mocha unit tests inside Visual Studio using the built-in tools like the Unit Test Explorer. I’m using this VSIX for years, and it works great.

But what if you want to run these same tests as part of your build process? I’ll explain the steps to get it up and running inside TFS Build vNext.

  • Start by opening the solution that contains the test project in Visual Studio.
  • Add the NuGet package for the Chutzpah test runner to your solution, this is a solution level package, so does not need to be associated with any project.
    • Don’t forget to check-in the change into source control Smile
  • Now go to the TFS web portal. Open your build definition and add a Visual Studio Test build task:


  • Configure the Test Assembly parameter inside the task to search for your JavaScript tests. All my JavaScript tests have ‘test’ as part of their filename so I used the following pattern; **\$(BuildConfiguration)\*test*.js;-:**\obj\**


  • That’s all. As we added the Chutzpah Test Runner adapter through NuGet, the build task will automatically pick it up and use it while executing the tests.
    • In case the test adapter isn’t discovered, you can still configure it manually by specifying the ‘Path to Custom Test Adapters’ parameter.


No comments: