Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
feat(runner): add mocha options to config file
Browse files Browse the repository at this point in the history
change lib/runner to allow setting mocha options from config.
  • Loading branch information
jmbarbier authored and juliemr committed Jan 22, 2014
1 parent 8e096b9 commit 66c4774
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/using-mocha.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
9 changes: 5 additions & 4 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ var config = {
showColors: true,
includeStackTrace: true,
stackFilter: protractor.filterStackTrace
},
mochaOpts: {
ui: 'bdd',
reporter: 'list'
}
}

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions referenceConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
};

0 comments on commit 66c4774

Please sign in to comment.