From 66c4774aa18d94d4da81c101b82db4a748cf69a4 Mon Sep 17 00:00:00 2001 From: JM Barbier Date: Fri, 3 Jan 2014 21:09:11 +0100 Subject: [PATCH] feat(runner): add mocha options to config file change lib/runner to allow setting mocha options from config. --- docs/using-mocha.md | 9 +++++++++ lib/runner.js | 9 +++++---- referenceConf.js | 8 ++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/using-mocha.md b/docs/using-mocha.md index 283575ded..6bb2dad8b 100644 --- a/docs/using-mocha.md +++ b/docs/using-mocha.md @@ -33,4 +33,13 @@ expect(myElement.getText()).to.eventually.equal('some text'); Finally, set the 'framework' property of the config to 'mocha', either by adding `framework: mocha` to the config file or adding `--framework=mocha` to the command line. +Options for mocha such as 'reporter', 'slow', can be given in config file with `mochaOpts` : + +```javascript +mochaOpts: { + reporter: "spec", + slow: 3000 +} +``` + See a full [example in protractor's own tests](https://github.com/angular/protractor/tree/master/spec/mocha). diff --git a/lib/runner.js b/lib/runner.js index 4f656aae1..a12e68ce4 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -32,6 +32,10 @@ var config = { showColors: true, includeStackTrace: true, stackFilter: protractor.filterStackTrace + }, + mochaOpts: { + ui: 'bdd', + reporter: 'list' } } @@ -277,10 +281,7 @@ var runTests = function() { } else if (config.framework == 'mocha') { var Mocha = require('mocha'); - mocha = new Mocha({ - ui: 'bdd', - reporter: 'list' - }); + mocha = new Mocha(config.mochaOpts); resolvedSpecs.forEach(function(file) { mocha.addFile(file); diff --git a/referenceConf.js b/referenceConf.js index d93616a64..046d9931e 100644 --- a/referenceConf.js +++ b/referenceConf.js @@ -121,4 +121,12 @@ exports.config = { // Default time to wait in ms before a test fails. defaultTimeoutInterval: 30000 } + + // ----- Options to be passed to mocha ----- + // + // See the full list at http://visionmedia.github.io/mocha/ + mochaOpts: { + ui: 'bdd', + reporter: 'list' + } };