0vtrla
Last Updated: September 20, 2018
·
3.079K
· calamari

Make jasmine:ci use phantomjs (under Rails)

If you write jasmine specs within your rails app you probably know, that rake jasmine will start a webrick server serving your jasmine test suite under localhost:8888. You also probably know that you also can run your test suite using a selenium driver with the rake jasmine:ci command. This will start a server, spawn of a firefox instance that navigates to the test suite and after it has run, it will tell in your console if it failed or succeeded.

Making it headless

But running firefox is slow. You really want to use a headless browser for testing it. It's also good for jenkins (or any other continuous integration system). So, why not use PhantomJS?

You do not know how?

Well, I didn't really do either, until yesterday when a colleague finally looked into the jasmine-gem code. It's simple (but undocumented), so here it goes:

Install PhantomJS and then add a file called spec/javascripts/support/jasmine_helper.rb into your rails app with the following contents:

Jasmine.configure do |config|
  config.browser = :phantomjs
end

Thats it. Just runrake jasmine:ci` and see for yourself.

2 Responses
Add your response

9084

Doing this on Ubuntu 12.04, hit a problem with Jasmine server not being found. Turned out I had an OLD version of PhantomJS (1.4) via apt package manager - so do make sure you get a later version from the site (1.9.1, currently).

Great tip - just what I was after

over 1 year ago ·
30751

Hallo Freunde, wenn Sie whatsapp Konto online hacken und auf ihre Bilder, Nachrichten und Fotos zugreifen möchten, dann besuchen Sie einfach hier und erhalten Sie Online-Tutorial für diese. http://whatshacken.com/

3 months ago ·