Skip to content

Commit

Permalink
Add test-case for watcher reacting on files in options.require
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Apr 8, 2019
1 parent 8e9de4f commit 0de4077
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
sources: ['source.custom-ext']
sources: ['source.custom-ext', 'setup.js']
};
24 changes: 24 additions & 0 deletions test/integration/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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-*.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;

Expand Down

0 comments on commit 0de4077

Please sign in to comment.