How can I run Jasmine tests with Karma (was Testacular) from Bamboo?
Asked Answered
D

1

10

While building a single page app with AngularJS, I'm trying to integrate Jasmine tests in my build.

I did something similar before with the Maven Jasmine plugin, but I don't like to wrap my project in maven just to run the Jasmine tests. It seems cleaner to use Karma (was Testacular) for this somehow.

I'm comfortable that I'll get things running from a shell command, and my guess is that I can then run the command from Bamboo.

My questions:

  • Am I on the right track?
  • How can I best fail the build from a script, or does Bamboo recognize the Karma output automatically?
Decahedron answered 30/10, 2012 at 7:28 Comment(0)
S
8

Great question. Make sure testacular.conf.js is configured to output junit xml for consumption by bamboo

junitReporter = {
  // will be resolved to basePath (in the same way as files/exclude patterns)
  outputFile: 'test-results.xml'
};

You can configure Testacular to run against many browsers and is pre-configured to use Chrome, we've chosen to start going headless with PhantomJS to do unit testing. Testacular already has jasmine inside.

For CI we are following the recommendation in

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = true;

If you use Ant a lot (and we do) sometimes you just want to stick with what you know... so you may want to checkout ANT, Windows and NodeJS Modules. to run node modules (ie testacular).

One note, if you are running testacular on windows, the npm install of testacular fails on hiredis module, which seems to be just *nix friendly. So, far it works fine without it.

It took us a couple of hours to prove all of this works. Hope this helps

--dan

Snowslide answered 30/10, 2012 at 7:28 Comment(1)
Great, thanks for sharing. I'll comment back here or edit if I have found some things that could use clarification. Especially the junitReporter tip is a gem.Decahedron

© 2022 - 2024 — McMap. All rights reserved.