I’ve been working on my VS Code Profile Switching Extension and one thing that I wanted to ensure I was doing in it was writing tests. There’s a good guide on writing tests from the VS Code team which I recommend you read if you’re an extension author.
In this post, I want to look at how we can combine the output of our test runs in a Continuous Integration pipeline, for which I’ll be using Azure Pipelines (which is free for open source projects!).
Generating Test Output for Azure Pipelines
Azure Pipelines supports a number of different test result formats in the Publish Test Results task that we’ll need to use and one of those is Xunit which Mocha supports out of the box.
Great, we can set the reporter to
xunit by updating the test runner script:
And this works nicely… except the
xunit output is an XML file which, might be readable by a computer but it’s not ideal for local testing, I’d much prefer to use Spec (or Nyan!), but Mocha only supports a single reporter as the output.
Using Multiple Reports
Thankfully, someone in the community has created a reporter for Mocha which is a pass-through that allows you to output to multiple reporters!
Start by installing
Now we can change the way we configure Mocha to use as many output reporters as we want:
Once combined with the Azure Pipeline task for publishing test results we’ll now see the output in Azure Pipelines!
You can check out my extensions Azure Pipelines.