diff --git a/test/fixture/watcher/with-custom-ext-dependencies/ava.config.js b/test/fixture/watcher/with-custom-ext-dependencies/ava.config.js index b4b3f63a6..f68647003 100644 --- a/test/fixture/watcher/with-custom-ext-dependencies/ava.config.js +++ b/test/fixture/watcher/with-custom-ext-dependencies/ava.config.js @@ -1,3 +1,3 @@ export default { - sources: ['source.custom-ext'] + sources: ['source.custom-ext', 'setup.js'] }; diff --git a/test/integration/watcher.js b/test/integration/watcher.js index df3d4926f..69a2adce9 100644 --- a/test/integration/watcher.js +++ b/test/integration/watcher.js @@ -85,7 +85,7 @@ test('watcher reruns test files when source dependencies change', t => { test('watcher reruns ONLY test files that depend on a changed source with custom extension', t => { let killed = false; - const child = execCli(['--verbose', '--require', './setup.js', '--watch', 'test-*.js'], {dirname: 'fixture/watcher/with-custom-ext-dependencies', env: {CI: ''}}, err => { + const child = execCli(['--verbose', '--require', './setup.js', '--watch', 'test-1.js', 'test-2.js'], {dirname: 'fixture/watcher/with-custom-ext-dependencies', env: {CI: ''}}, err => { t.ok(killed); t.ifError(err); t.end(); @@ -106,6 +106,30 @@ test('watcher reruns ONLY test files that depend on a changed source with custom }); }); +test('watcher reruns all tests when one of the configured files in the `require` option changes', t => { + let killed = false; + + const child = execCli(['--verbose', '--require', './setup.js', '--watch', 'test-1.js', 'test-2.js'], {dirname: 'fixture/watcher/with-custom-ext-dependencies', env: {CI: ''}}, err => { + t.ok(killed); + t.ifError(err); + t.end(); + }); + + let buffer = ''; + let passedFirst = false; + child.stdout.on('data', str => { + buffer += str; + if (buffer.includes('2 tests passed') && !passedFirst) { + touch.sync(path.join(__dirname, '../fixture/watcher/with-custom-ext-dependencies/setup.js')); + buffer = ''; + passedFirst = true; + } else if (buffer.includes('2 tests passed') && !killed) { + child.kill(); + killed = true; + } + }); +}); + test('watcher does not rerun test files when they write snapshot files', t => { let killed = false;