Skip to content

Commit

Permalink
Don't re-initialize grep option on watch re-run
Browse files Browse the repository at this point in the history
We remove code that called `mocha.grep(null)` on watch re-runs if the
`--grep` option was not supplied. The code seems to serve no purpose and
is the cause of mochajs#2027.
  • Loading branch information
Thomas Scholtes committed Jun 27, 2019
1 parent 5d4dd98 commit b214862
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ exports.runMocha = (mocha, options) => {
const {
watch = false,
extension = [],
grep = '',
ui = 'bdd',
exit = false,
ignore = [],
Expand All @@ -138,7 +137,7 @@ exports.runMocha = (mocha, options) => {
};

if (watch) {
watchRun(mocha, {ui, grep}, fileCollectParams);
watchRun(mocha, {ui}, fileCollectParams);
} else {
exports.singleRun(mocha, {exit}, fileCollectParams);
}
Expand Down
6 changes: 1 addition & 5 deletions lib/cli/watch-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ const collectFiles = require('./collect-files');
* Run Mocha in "watch" mode
* @param {Mocha} mocha - Mocha instance
* @param {Object} opts - Options
* @param {string|RegExp} opts.grep - Grep for test titles
* @param {string} opts.ui - User interface
* @param {Object} fileCollectParams - Parameters that control test
* file collection. See `lib/cli/collect-files.js`.
* @param {string[]} fileCollectParams.extension - List of extensions to watch
* @private
*/
module.exports = (mocha, {grep, ui}, fileCollectParams) => {
module.exports = (mocha, {ui}, fileCollectParams) => {
let runner;
const files = collectFiles(fileCollectParams);

Expand Down Expand Up @@ -64,9 +63,6 @@ module.exports = (mocha, {grep, ui}, fileCollectParams) => {
const rerun = () => {
purge();
eraseLine();
if (!grep) {
mocha.grep(null);
}
mocha.suite = mocha.suite.clone();
mocha.suite.ctx = new Context();
mocha.ui(ui);
Expand Down

0 comments on commit b214862

Please sign in to comment.