diff --git a/lib/watcher.js b/lib/watcher.js index 3f5ed3ee7..82538de41 100644 --- a/lib/watcher.js +++ b/lib/watcher.js @@ -1,5 +1,6 @@ 'use strict'; const nodePath = require('path'); +const chalk = require('chalk'); const debug = require('debug')('ava:watcher'); const diff = require('lodash.difference'); const chokidar = require('chokidar'); @@ -18,6 +19,7 @@ function rethrowAsync(err) { const MIN_DEBOUNCE_DELAY = 10; const INITIAL_DEBOUNCE_DELAY = 100; +const rerunMessage = chalk.gray.dim(`To rerun all tests, type 'r', followed by Enter\nTo update snapshots used in the previous tests, type 'u', followed by Enter\n`); class Debouncer { constructor(watcher) { @@ -126,6 +128,7 @@ class Watcher { .then(runStatus => { runStatus.previousFailCount = this.sumPreviousFailures(currentVector); logger.finish(runStatus); + logger.write(rerunMessage); const badCounts = runStatus.failCount + runStatus.rejectionCount + runStatus.exceptionCount; this.clearLogOnNextRun = this.clearLogOnNextRun && badCounts === 0; diff --git a/test/cli.js b/test/cli.js index ed2805734..54fcb7c87 100644 --- a/test/cli.js +++ b/test/cli.js @@ -325,7 +325,9 @@ test('watcher does not rerun test files when they write snapshot files', t => { killed = true; }, 500); } else if (passedFirst && !killed) { - t.is(buffer.replace(/\s/g, ''), ''); + const rerunMessage = `To rerun all tests, type 'r', followed by Enter\nTo update snapshots used in the previous tests, type 'u', followed by Enter\n`; + const rerunMessageWithoutWhitespace = rerunMessage.replace(/\s/g, ''); + t.is(buffer.replace(/\s/g, ''), rerunMessageWithoutWhitespace); } }); }); diff --git a/test/watcher.js b/test/watcher.js index bb8e70bdc..1fa3d08af 100644 --- a/test/watcher.js +++ b/test/watcher.js @@ -78,7 +78,8 @@ group('chokidar', (beforeEach, test, group) => { finish: sinon.spy(), section: sinon.spy(), clear: sinon.stub().returns(true), - reset: sinon.spy() + reset: sinon.spy(), + write: sinon.spy() }; api = { @@ -210,7 +211,7 @@ group('chokidar', (beforeEach, test, group) => { }); test('starts running the initial tests', t => { - t.plan(8); + t.plan(10); let done; api.run.returns(new Promise(resolve => { @@ -223,6 +224,7 @@ group('chokidar', (beforeEach, test, group) => { t.ok(logger.clear.notCalled); t.ok(logger.reset.notCalled); t.ok(logger.start.notCalled); + t.ok(logger.write.notCalled); t.ok(api.run.calledOnce); t.strictDeepEqual(api.run.firstCall.args, [files, defaultApiOptions]); @@ -232,6 +234,7 @@ group('chokidar', (beforeEach, test, group) => { return delay().then(() => { t.ok(logger.finish.calledOnce); t.is(logger.finish.firstCall.args[0], runStatus); + t.ok(logger.write.calledOnce); }); });