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 May 6, 2019
1 parent bc6f928 commit 4649664
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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']
};
26 changes: 25 additions & 1 deletion test/integration/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;

Expand Down

0 comments on commit 4649664

Please sign in to comment.