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

Commit 66c4774

Browse files
jmbarbierjuliemr
authored andcommitted
feat(runner): add mocha options to config file
change lib/runner to allow setting mocha options from config.
1 parent 8e096b9 commit 66c4774

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

docs/using-mocha.md

+9
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ expect(myElement.getText()).to.eventually.equal('some text');
3333

3434
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.
3535

36+
Options for mocha such as 'reporter', 'slow', can be given in config file with `mochaOpts` :
37+
38+
```javascript
39+
mochaOpts: {
40+
reporter: "spec",
41+
slow: 3000
42+
}
43+
```
44+
3645
See a full [example in protractor's own tests](https://github.com/angular/protractor/tree/master/spec/mocha).

lib/runner.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ var config = {
3232
showColors: true,
3333
includeStackTrace: true,
3434
stackFilter: protractor.filterStackTrace
35+
},
36+
mochaOpts: {
37+
ui: 'bdd',
38+
reporter: 'list'
3539
}
3640
}
3741

@@ -277,10 +281,7 @@ var runTests = function() {
277281
} else if (config.framework == 'mocha') {
278282
var Mocha = require('mocha');
279283

280-
mocha = new Mocha({
281-
ui: 'bdd',
282-
reporter: 'list'
283-
});
284+
mocha = new Mocha(config.mochaOpts);
284285

285286
resolvedSpecs.forEach(function(file) {
286287
mocha.addFile(file);

referenceConf.js

+8
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,12 @@ exports.config = {
121121
// Default time to wait in ms before a test fails.
122122
defaultTimeoutInterval: 30000
123123
}
124+
125+
// ----- Options to be passed to mocha -----
126+
//
127+
// See the full list at http://visionmedia.github.io/mocha/
128+
mochaOpts: {
129+
ui: 'bdd',
130+
reporter: 'list'
131+
}
124132
};

0 commit comments

Comments
 (0)