Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I switch from Vows to Mocha?

I'm trying to decide whether to switch from Vows to Mocha for a large Node app.

I've enjoyed almost all of the Vows experience - but there is just something strange about the argument passing. I always have to scratch my head to remember how topics work, and that interferes with the basics of getting the tests written. It is particularly problematic on deeply nested asynchronous tests. Though I find that combining Vows with async.js can help a little.

So Mocha seems more flexible in its reporting. I like the freedom to choose the testing style & importantly it runs in the browser too, which will be very useful. But I'm worried that it still doesn't solve the readability problem for deeply nested asynchronous tests.

Does anyone have any practical advice - can Mocha make deeply nested tests readable? Am I missing something?

like image 597
Joe Parry Avatar asked Feb 13 '12 10:02

Joe Parry


2 Answers

Mocha is ace. It provides a done callback, rather than waitsFor that jasmine provides. I cant speak about migration from vows but from jasmine it was straight forward. Inside you mocha test function you can use async if you want (or Seq etc.. if you want to be legacy) though if you required nested callbacks at that point its an integration test, which might make you think about the granularity of your tests.

OT: 100% test coverage rarely delivers any value.

like image 146
Mâtt Frëëman Avatar answered Nov 06 '22 20:11

Mâtt Frëëman


Deeply nested tests are solved by using flow control in your unit test suite.

Vows does not allow this easily because the exports style requires creating flow control libraries that support this.

Either write a flow control library for vows or switch to mocha and re-use an existing flow control library.

like image 3
Raynos Avatar answered Nov 06 '22 19:11

Raynos