Running Jasmine Tests with phantomjs

Posted by Anuraj on Tuesday, December 1, 2015

Jasmine PhantomJS

Last post is about writing javascript unit tests. This post is about integrating Jasmine tests in Continuous Integration. For integrating in CI, you need an application - PhantomJS. PhantomJS is a headless WebKit scriptable with a JavaScript API. You can download PhantomJS from the PhantomJS download page.. To run Jasmine test cases you also require run-jasmine.js.

You can invoke it with phantomjs from command line and based test case results, exit code will change.

phantomjs.exe run-jasmine.js <Test Page URL>

And here is the screenshot of the console, where Jasmine unit tests are running.

Unit Test - Results from console

In Travis CI - phantomjs.exe pre-installed, so you don’t need to install it seperatly. And if unit tests are failing the exit code will be “1” and if every unit tests passed exit code is “0”.

Happy Coding.



Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



MVP
Subscribe


Copyright © 2017 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub