Sean Killeen
Posted on • Originally published atseankilleen.com on
How to: Show Jasmine test results in TeamCity
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:
varJasmine=require('jasmine');varreporters=require('jasmine-reporters');varjasmine=newJasmine();// 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});jasmine.execute();
- Prior to executing the steps, add the TeamCity reporter:
varteamCityReporter=newreporters.TeamCityReporter();jasmine.configureDefaultReporter(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:
varnunitXmlReporter=newreporters.NUnitXmlReporter();jasmine.addReporter(nunitXmlReporter);
Updating TeamCity
- Open the build in question
- From the Menu, 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):
- Double-check the saved feature:
The Results
We see our tests listed in the build list:
And we see the test output in the overview tab:
And we see the a tests tab with the output of each individual test:
Hope this helps! Happy testing!
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse