Skip to main content

JavaScript: Jasmine

I went to a talk the other day on Jasmine:
Jasmine is a behavior-driven development framework for testing your 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.
describe("Jasmine", function() {
it("makes testing JavaScript awesome!", function() {
expect(yourCode).toBeLotsBetter();
});
});
Jasmine started life at Pivotal Labs and is like RSpec for JavaScript. Thanks to the flexibility of JavaScript, it has a powerful mocking / stubbing framework. Jasmine is not a replacement for Selenium. It's good for testing JavaScript functions that calculate things, but it doesn't try to make testing the DOM any easier. Just as unit tests written using RSpec are not a replacement for integration tests written using Cucumber and Webrat, similarly unit tests written using Jasmine are not a replacement for integration tests written using Selenium. Nonetheless, it looks useful.

Comments