mocha testing in electron
Install it with npm and make sure you've installed electron-prebuilt globally as well.
npm install -g electron-prebuiltnpm install --save-dev mochatron
Use the script from the command line or node.
Note: by default the electron window isn't shown so that the test runs 'headless', but for debugging it can be helpful to see the window so in the config set 'window' to true or pass the '-w' argument.
node .\node_modules\mochatron -w http://localhost/
var mochatron = ;;
I haven't gotten around to making plugins for gulp or grunt yet (Contributions is this area would be welcome) but in the meantime here is an example of how the script can be used from a gulp task.
var gulp = ;var mochatron = ;gulp;
You also need to make sure you are including the mocha scripts on the page. If you have already been using mocha for browser testing then this step might already be done for you, but if you haven't, an example of the HTML code required to include mocha might look like this.
Note the call to
mochatron AFTER mocha / chai and your test.js file.
Here's an example of how to call mochatron with all of its default options and comments about them.
For command line usage this should give you an idea of what arguments can be passed.
var program = ;// Handle command line usage.programversion'1.0.2';
node .\node_modules\mochatron -w -s http://localhost/
Contributions and suggestions are welcome! Please feel free to open an issue if you run into a problem or have a feature request. I'll do my best to respond in a timely fashion.
If you want to open a pull request just fork the repo but please make sure all tests and lint pass first.