28

I've been looking at two libraries for doing unit tests on the front-end.

  • QUnit - http://qunitjs.com/

  • Jasmine - http://jasmine.github.io/

    1. Jasmine is clearly more BDD focused than QUnit although I could see doing BDD with QUnit by describing the tests in a behavior-oriented way. Both of them are able to run assertions on units of code so I think they're both unit tests. Is BDD mutually exclusive from TDD or is it all in how you write it?

    2. Is unit testing necessary if you're doing behavior testing? Seems like if you cover all user stories, you don't really need to know the details of the testable units.

    3. Are there any other testing frameworks you like? Are there other tests besides unit tests that are good for devs to do on the front-end?

3
  • BDD is essentially a friendly way of describing TDD methodologies. Aug 11, 2013 at 14:08
  • 7
    I appreciate how your first and second questions turn what would otherwise be a subjective Q&A into a more objective one.
    – nshew13
    Feb 21, 2014 at 16:53
  • pivotal.github.io/jasmine is page not found Nov 26, 2014 at 14:41

2 Answers 2

20
  1. BDD and TDD are not mutually exclusive. See Liz Keogh's post

  2. Behavior testing should be understandable by business stakeholders. Unit testing is typically intended to be understood by technical team members (developers, testers etc.). For examples of how to make unit tests more readable you should look at the GOOS book (although the examples are Java not Javascript).

    Also, if you try to cover all test paths using BDD, your business people will get bored and stop caring.

  3. Have a look at Cucumber-JS (a port of Cucumber).

2
  • 17
    I'd like to see a study that shows the percentage of business stakeholders that actually read the BDD tests. I bet it's in the single digits.
    – user9903
    Sep 10, 2013 at 15:19
  • 3
    You may be right, but they certainly won't read them if they can't understand them. Have a look at the online BDD tests for the UK government's redevelopment of their public website at relishapp.com/GDS/whitehall/docs
    – Seb Rose
    Sep 10, 2013 at 21:00
-3

If you are looking at writing tests that involve DOM interactions I'd have a look at pageboy.js. This is a new project that provides a Domain Specific Language (DSL) for Javascript DOM interactions (a bit like Capybara which is used within Cucumber in Ruby), which is intended to make test code more readable.

There is more on the background of this DSL here.

2
  • 3
    A disclaimer (on your involvement in the project) would be nice. May 10, 2016 at 16:04
  • Last commit 3 years ago Feb 20, 2017 at 2:16

Your Answer

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

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