How to: Show Jasmine test results in TeamCity

1 minute read | Suggest an edit | Issue? Question?

A colleague wanted to surface their jasmine tests in a TeamCity build system. Wanted to document the steps I used to help them solve their problem.

Setting up the Jasmine Output

  • Add the jasmine-reporters package: npm -i jasmine-reporters --save-dev
  • Add an index.js to set up the tests if you haven’t already:
var Jasmine = require('jasmine');

var reporters = require('jasmine-reporters');

var jasmine = new Jasmine();

// Load configuration from a file or from an object. jasmine.loadConfig({
    "spec_dir": "spec",
    "spec_files": [
      "**/*\[sS]pec.js"     ],
    "helpers": [
      "helpers/**/*.js"     ],
    "stopSpecOnExpectationFailure": false,
    "random": true

  • Prior to executing the steps, add the TeamCity reporter:
var teamCityReporter = new reporters.TeamCityReporter();

  • Update the “test” or “tests” command in your package.json:
"tests": "node .path/to/specs/index.js"
  • Prior to executing, add an additional NUnit XML Reporter:
var nunitXmlReporter = new reporters.NUnitXmlReporter();


Updating TeamCity

  • Open the build in question
  • From the Menu, add a build feature:

TeamCity build menu showing the option to add a build feature

  • Select the “XML Report Processing” feature, choose an NUnit-style report, and point it to nunitresults.xml (the default location for the jasmine NUnit output):

XML report processing options

  • Double-check the saved feature:

The added build feature

The Results

We see our tests listed in the build list:

Tests in the build list

And we see the test output in the overview tab:

Tests in the overview page of the build

And we see the a tests tab with the output of each individual test:

Tests in the build's tests tab

Hope this helps! Happy testing!

Leave a comment