7

Are there any approaches and tools for driving the development of JavaScript with BDD. I know that I can do this through the UI with tools like Selenium, but is there any tool that can allow this to happen at the unit testing level?

I would ideally like to write scenarios for the JavaScript behaviors and use unit tests to prove that the JavaScript works.

3 Answers 3

5

Jasmine is a BDD tool for JavaScript.

4

In the company I'm currently working on, we tested out some testing frameworks out there, and we finally decided to go with Jasmine. This is what we found:

  • JsUnit: This is one of the oldest unit testing framework, that was later being maintained by Pivotal Labs. But even they are using Jasmine now :P.
  • JSpec: This is an RSpec like BDD unit testing framework. We didn't like some of the ways things are done with it, as well as the magic strings in "expect(cart).to(receive, 'addProduct', 'twice')"
  • Jasmine: This is RSpec like as well and was the one that we found was more complete and easy to use and implement. You definitely have to try it out. The easiness of running it's web server (with just rake jasmine), along it's easy extensiveness (implementing matchers is really easy) made it our preferred option.

To complement this, I would also suggest you take a look at these exquisite libraries:

0

Use Jasmine(BDD test frame work) with Karma (test runner).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.