Skip to content

Commit

Permalink
feat(timeout): add timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
blond committed Mar 23, 2016
1 parent dfc68ec commit e64bc20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ module.exports = function (config) {
- *String[]* `exclude` – маски путей, которые необходимо исключить при формировании отчета. По умолчанию — `['**/node_modules/**', '**/libs/**']`;
- *String[]* `reporters` – форматы отчетов (env: `BEM_TMPL_SPECS_COV_REPORTERS`, названия форматов отчётов передаются через запятую), см. [istanbul#report](https://github.com/gotwarlost/istanbul/tree/master/lib/report). По умолчанию – `['lcov']`.
* *Object* `htmlDiffer` — настройки сравнения HTML при помощи [html-differ](https://ru.bem.info/tools/testing/html-differ/). По умолчанию — `{ preset: 'bem' }`.
* *Number* `timeout` — время ожидания тест-кейса в миллисекундах (env: `BEM_TMPL_SPECS_TIMEOUT`).
* *String|RegExp* `grep` — фильтр тестов по названию (env: `BEM_TMPL_SPECS_GREP`), см. [mocha#grep](http://mochajs.org/#grep-option).

### Опции для определенного уровня-сета
Expand Down
4 changes: 3 additions & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ function initCommonOpts(opts) {
opts || (opts = {});

var covReporters = process.env.BEM_TMPL_SPECS_COV_REPORTERS,
grep = process.env.BEM_TMPL_SPECS_GREP;
grep = process.env.BEM_TMPL_SPECS_GREP,
timeout = process.env.BEM_TMPL_SPECS_TIMEOUT;

return {
coverage: opts.coverage && _.defaults(opts.coverage === true ? {} : opts.coverage, {
Expand All @@ -225,6 +226,7 @@ function initCommonOpts(opts) {
],
reporters: covReporters ? covReporters.split(',') : ['lcov']
}),
timeout: timeout || 2000,
grep: (typeof grep === 'undefined' ? opts.grep : grep) || false,
diffOpts: _.defaults(opts.htmlDiffer || {}, { preset: 'bem' })
};
Expand Down
3 changes: 2 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ function Runner(opts) {
this._mocha = new Mocha({
ui: 'bdd',
reporter: runReporters(opts.diffOpts),
grep: parseRe(opts.grep)
grep: parseRe(opts.grep),
timeout: opts.timeout
});
}

Expand Down

0 comments on commit e64bc20

Please sign in to comment.