Tony Lukasavage

Caffeine. Whiskey. Code. Mostly the last one.

ti-mocha: Mocha testing support for Titanium

| Comments


The Appcelerator community has long been asking for a clear choice for unit testing. While many (including myself) have used Jasmine, I have over time gained preference for another. Mocha has quickly become my unit testing framework of choice for all node.js development, due to its stability, flexibility, and the consistently awesome work of its author, TJ Holowaychuk. There was one small problem. It didn’t work out of the box with Titanium. And even once you got past the critical breaking issues, you still had the fact that Titanium Studio and the Titanium.API log functions weren’t compatible with almost any of mocha’s reporters.

But no longer. ti-mocha resolves these issues and is ready for use in your Titanium apps. I’m not going to ramble on here, since pretty much everything is covered on the documentation website, but here’s the highlights:

  • Full support for the mocha framework
  • Compatible with the should.js assertion library, which I highly recommend
  • The ti-spec and ti-spec-studio Titanium reporters, optimized for terminal and Titanium Studio, respectively
  • Detailed examples of how to use ti-mocha + should.js in your Titanium apps
  • A bunch more, so just got check it out

You’ve got one less reason to not be unit testing your Titanium apps. So grab ti-mocha, get to it, and let me know what you think.

Resources & Links

Comments