node-webkit bleak testing situation with Mocha

8 views
Skip to first unread message

james.m...@a-cti.com

unread,
Apr 24, 2014, 2:48:43 AM4/24/14
to node-...@googlegroups.com
I took some time to look through all of the tests for node-webkit to get a better idea how I can use Mocha in my own node-webkit project.  Currently, I'm using QUnit.  It was easy to setup, and I was up and running in minutes.  However, we know node-webkit uses Mocha for testing, so we thought it would be a good idea to do the same.

After digging in, it appears that node-webkit developers might want to rethink using Mocha for testing.  Here's why:
  • Moreover, the current Mocha version used for testing in node-webkit is 1.7.4.  The latest version is now 1.14.0.  Mocha stops working in node-webkit as of version 1.12.0.  For context, 1.12.0 was released 10 months ago:  https://github.com/visionmedia/mocha/releases/tag/1.12.0
I've already spent more time on setting up testing than I'd like to, and after seeing the situation and spending time trying to force a square peg in a round hole. I'm thinking QUnit (or at least, not Mocha) might be a better option.

Here's what I have with QUnit so far:
  • I'm watching files for changes using Gaze.  Every time I save, the tests re-run automatically.
  • QUnit works out of the box in node-webkit.  I follow the Getting Started instructions and had tests setup in minutes.
  • Sinon, however, won't load in node-webkit. So I'm still looking for stubs and mocks alternatives.
  • I developed a module to allow me to run node-webkit from the terminal and read command line arguments, so I can choose to launch the app, run the tests, or do both.

Overall, it seems that any framework that uses require (not Node.js require but CommonJS require) will likely have trouble running in node-webkit.

james.m...@a-cti.com

unread,
Apr 29, 2014, 8:33:37 PM4/29/14
to node-...@googlegroups.com, james.m...@a-cti.com
UPDATE:

I eventually ran into a snag with QUnit where SinonJS would not load in node-webkit: https://github.com/cjohansen/Sinon.JS/issues/474.  So I moved over to Jasmine 2.0.  
  • Jasmine 2.0 worked out of the box.
  • Jasmine 2.0 loaded in the web context.
  • Synchronous tests work.
  • Asynchronous tests work.
  • Spies work.
Out of the three libraries, Mocha, QUnit, and Jasmine, Jasmine was the easiest to get setup with where the above items worked without crazy workarounds, such as redefining "require" and other globals.

I would really appreciate if someone who knows more than me can let me know if I'm just missing something here and that the latest version of Mocha will work as a node-webkit testing library without the workarounds.  If not, I hope the information here helps others.

Thank you,
James
Reply all
Reply to author
Forward
0 new messages