Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Jasmine tests in TeamCity

We have been writing specifications for our JavaScript business logic using Jasmine. We're able to run our test suite within a browser, but how would we integrate this within TeamCity? Preferrably we do not want to use NodeJS, rather something as simple as possible.

like image 412
Daniel Lidström Avatar asked Jan 17 '14 11:01

Daniel Lidström


People also ask

Where does Jasmine look for test files?

The jasmine. json file in the spec/support folder configures Jasmine. The src is the folder to search for spec files.

Do Jasmine tests run in order?

x) Jasmine runs tests in the order they are defined.


1 Answers

I have created a modified version of run-jasmine.js that is found in the PhantomJS sources (original version is here. This version can be used within TeamCity (it will automatically detect that it is running in TeamCity). This updated version is using TeamCity service messages which allows for a nice integration.

You will need PhantomJS. You'll also need one of the following:

  • run-jasmine.js (for Jasmine 1.x).
  • run-jasmine.js (for Jasmine 2.x).

Add a build step in your TeamCity build configuration that can run this step:

phantomjs.exe run-jasmine.js index.html

index.html is your Jasmine runner page. If the build agents do not include PhantomJS, you can commit it to your repository along with your sources (this is what we do).

The result will look like this:

Tests Overview

Test details: Test Details

The above is from a Tasks sample ASP.NET MVC project with this setup. It can be run in TeamCity using a Visual Studio (sln) build step. It will also run the tests within Visual Studio, as a pre-build step.

like image 101
Daniel Lidström Avatar answered Oct 30 '22 02:10

Daniel Lidström