Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we run JavaScript jasmine tests from Jenkins (Hudson) without loading a JSP?

We have a rich web client. Our controllers and service facades are written in coffeescript (JavaScript) and jquery. In the past they would have been java.

To run our JavaScript jasmine tests from Jenkins/Hudson, we use java's junit and htmlunit to load a test oriented jsp page which includes the jasmine specs.

When the Htmlunit tries to run, it blows up trying to getPage() probably because of an XML parser class path which is extremely challenging to track down in our world.

We just want to be able to run our JavaScript tests from Jenkins and have it report failure if a JavaScript test does not pass. We are just using jsp and htmlunit in order to run JavaScript tests. Can we load the JavaScript tests and javascript code into a JavaScript engine with Jenkins as the thing that kicks it off? If so, how?

like image 536
finneycanhelp Avatar asked Sep 30 '11 10:09

finneycanhelp


People also ask

How does Jenkins integrate with Jasmine?

Jenkins SettingsIn your Jenkins project configuration screen, click the Add Build Step button and add a “Publish JUnit test result report” step. Enter 'reports/*. xml' as the `Test report XMLs` field. If you've already got Jenkins running your test script then you're all done.

Can Jasmine test standalone JavaScript code?

Jasmine can be used as a standalone application where you download the framework and put your JavaScript files inside the src folder. Then you write the test files (often called "specs") and put them in the spec folder.

What kind of framework is Jasmine for testing JavaScript code?

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.


2 Answers

Sounds like you're in a Java environment. My jasmine-maven-plugin might be a good fit.

like image 142
Justin Searls Avatar answered Oct 17 '22 09:10

Justin Searls


Jasmine Reporters would also be a solution. It has instructions for running headlessly via PhantomJS for example, and it can generate JUnit XML so Jenkins can understand the test results natively, graphing test count, duration, and failure over time.

Also, the "xvfb-run" wrapper often provided with xvfb is a great help here, so you can do "xvfb-run phantomjs.runner.sh ..." in a truly headless environment.

like image 40
mrooney Avatar answered Oct 17 '22 09:10

mrooney