I am looking to convert from Jasmine tests to Mocha tests because of its ability to do Before(all), its reporting capabilities, and its support for coffeescript.
One thing I haven't been able to find is whether Mocha (or in conjunction with a compatible assertion library) supports fixtures like jasmine-jquery does (https://github.com/velesin/jasmine-jquery). Does such functionality exist for Mocha?
I'm trying to test some in-browser code (so I will be running it with the html test runner) that manipulates the DOM. I don't wish to use zombiejs because I'd prefer to run it within the environment I'm testing in.
Edit: Just for reference, while searching for a solution, I came across using grunt + mocha with a phantomjs implementation. This also doesn't work for my case as I'd like to use a custom version of webkit.
From what I've been able to figure out, the answer is no. This is probably due to the fact that Mocha was first meant to support node.js. In node, the notion of fixtures in jasmine-jquery doesn't exist because a DOM/browser doesn't exist.
Looking at the fixtures support for the jasmine-jquery plugin, I realize now that is may not be so difficult to build this functionality myself. The basic mechanism is to use jQuery to add an external template to the DOM, while retaining the references to it so that cleanup and caching is possible.
I will update this answer if I decide to release something on github
Edit: here it is - https://github.com/badunk/js-fixtures. The code and specs were essentially copied from jasmine-jquery with the dependencies removed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With