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 #2027.
  • Loading branch information
Thomas Scholtes committed Jun 25, 2019
1 parent ccee5f1 commit 66b4a04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 2 additions & 3 deletions lib/cli/run-helpers.js
Expand Up @@ -188,19 +188,18 @@ exports.singleRun = (mocha, {files = [], exit = false} = {}) => {
* @param {Object} [opts] - Options
* @param {boolean} [opts.watch=false] - Enable watch mode
* @param {string[]} [opts.extension] - List of extensions to watch
* @param {string|RegExp} [opts.grep] - Grep for test titles
* @param {string} [opts.ui=bdd] - User interface
* @param {boolean} [opts.exit=false] - Force-exit Mocha when tests done
* @param {string[]} [files] - Array of test files
* @private
*/
exports.runMocha = (
mocha,
{watch = false, extension = [], grep = '', ui = 'bdd', exit = false} = {},
{watch = false, extension = [], ui = 'bdd', exit = false} = {},
files = []
) => {
if (watch) {
watchRun(mocha, {extension, grep, ui, files});
watchRun(mocha, {extension, ui, files});
} else {
exports.singleRun(mocha, {files, exit});
}
Expand Down
6 changes: 1 addition & 5 deletions lib/cli/watch-run.js
Expand Up @@ -16,12 +16,11 @@ const Mocha = require('../mocha');
* @param {Mocha} mocha - Mocha instance
* @param {Object} opts - Options
* @param {string[]} opts.extension - List of extensions to watch
* @param {string|RegExp} opts.grep - Grep for test titles
* @param {string} opts.ui - User interface
* @param {string[]} opts.files - Array of test files
* @private
*/
module.exports = (mocha, {extension, grep, ui, files}) => {
module.exports = (mocha, {extension, ui, files}) => {
let runner;

console.log();
Expand Down Expand Up @@ -61,9 +60,6 @@ module.exports = (mocha, {extension, grep, ui, files}) => {
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 66b4a04

Please sign in to comment.