8

Most of the existing questions about unit testing JavaScript code and integrating it into a continuous integration environment seem to date back to the dawn of time (or at least 2008 or 2009 :) ). Even a recent one is from about a year and a half ago:

Running JavaScript unit tests headlessly in a Continuous Integration build

Before I launch into trying to use js-test-driver to build tests and integrate them into Jenkins (nee Hudson), is this still the best approach in 2011?

We've got code that uses JavaScript and jQuery, Lawnchair, lccache, Fancybox, and more. I don't think we have to test all of it, but it would be nice if we could build tests for a reasonable subset. Bonus points if the solution is happy with backbone.js. It's looking more and more likely as time wears on.

Community
  • 1
  • 1
John Munsch
  • 19,530
  • 8
  • 42
  • 72

3 Answers3

4

After some further looking into this, we're going to give Jasmine BDD a try for our testing. It's featured in the PeepCode videos on Backbone.js as well as this excellent article series about testing Backbone.js using Jasmine:

If we go down this route it appears we may have to combine it with JsTestDriver so we can plug the whole mess into Jenkins.

John Munsch
  • 19,530
  • 8
  • 42
  • 72
  • Are you guys using loadFixtures (from jasmine-jquery) in your test suites? If so how/do these work with JsTestDriver? – nav Jun 15 '12 at 07:55
  • @nav JsTestDriver has proven to be something of a nightmare running on Windows so the whole thing is tabled at the moment. I'm hoping to wrest a Linux server or VM from Ops at some point so I can return to making it work. – John Munsch Jun 15 '12 at 12:38
2

You could run Selenium tests together with Jenkins.

powtac
  • 40,542
  • 28
  • 115
  • 170
  • I like the fact that there's already a plugin for that. js-test-driver doesn't seem to have it quite as neat as that but it still doesn't look too bad: http://cjohansen.no/en/javascript/javascript_continuous_integration_with_hudson_and_jstestdriver – John Munsch Aug 30 '11 at 13:25
  • 4
    AFAIK, Selenium is more for functional testing of web apps, not unit testing of JavaScript. (Please tell me if I am wrong.) – Roy Tinker Jan 10 '12 at 02:20
1

For reference in case someone stumbles on this later on: there is also TestSwarm (used by the JQuery team) and Buster.js (up and coming JSTestDriver replacement)

gotofritz
  • 3,341
  • 1
  • 31
  • 47