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:
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.