Mnementh
Mnementh

Reputation: 51311

Which testing-framework for Javascript supports Testing without a browser?

For Javascript some testing-frameworks exist, like JSUnit or js-test-driver. They are fine, but they run the tests in a browser. That's fine, especially to verify your webapp is running in different browsers. But on out continuous-integration-server no window-system (and no browser) is installed. So is there a way to run the tests without the usage of a browser? The best would be to use one of the existing frameworks, so that developers can locally run the tests in their browsers and the continuous-integration-system runs them browserless.

Upvotes: 8

Views: 2679

Answers (6)

luc
luc

Reputation: 43096

You may be interested in HtmlUnit which is used by several UI-testing framework like WebDriver

Upvotes: 1

Ingvald
Ingvald

Reputation: 443

Take a look at the following articles:

In addition, we have a jsTestDriver server running with a couple of web browsers (as remote console runners) as a resource for Jenkins, so you can have CI with testing in web browsers.

Upvotes: 1

Pete Hodgson
Pete Hodgson

Reputation: 15845

Jasmine will run quite happily inside of node.js.

Upvotes: 0

Karl
Karl

Reputation: 1625

JSpec can be run without a browser (using Rhino). But also supports being run in browsers as well.

http://visionmedia.github.com/jspec/

It also provides a nice specification style syntax:

describe 'ShoppingCart'   
  describe 'addProduct'   
    it 'should add a product'  
      cart.addProduct('cookie') 
      cart.addProduct('icecream') 
      cart.should.have 2, 'products'   
    end   
  end 
end

By running all your unit tests outside of a browser, you also get the benefits of ensuring separation of your logic from the html/presentation layer (useful for web apps, possibly overkill for small scripts).

Upvotes: 0

B.E.
B.E.

Reputation: 5080

I believe Canoo WebTest can be run without a browser. It's basically a frontend-testing framework but can be used to test JavaScript as well:

http://webtest.canoo.com/

Upvotes: 0

geowa4
geowa4

Reputation: 41813

jsTest can be run command line or as an eclipse plugin.

However, be careful, you will not get 100% code coverage using a tool like this if you need to support multiple browsers. Each browser implements JavaScript differently (i.e.: IE). Therefore, the only way to fully test your JavaScript is to run the tests in all browsers that you support.

Upvotes: 1

Related Questions