Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch files starting with dot by default #1

Merged
merged 1 commit into from Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/cli/watch-run.js
Expand Up @@ -30,7 +30,10 @@ const collectFiles = require('./collect-files');
*/
module.exports = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
if (!watchFiles) {
watchFiles = fileCollectParams.extension.map(ext => `**/*.${ext}`);
watchFiles = fileCollectParams.extension.reduce(
(watchFiles, ext) => watchFiles.concat([`**/*.${ext}`, `**/.*.${ext}`]),
[]
);
}

const watcher = chokidar.watch(watchFiles, {
Expand Down
18 changes: 18 additions & 0 deletions test/integration/options/watch.spec.js
Expand Up @@ -137,6 +137,24 @@ describe('--watch', function() {
});
});

it('reruns test when file starting with . and matching --extension is changed', function() {
const testFile = path.join(this.tempDir, 'test.js');
copyFixture('__default__', testFile);

const watchedFile = path.join(this.tempDir, '.file.xyz');
touchFile(watchedFile);

return runMochaWatch(
[testFile, '--extension', 'xyz,js'],
this.tempDir,
() => {
touchFile(watchedFile);
}
).then(results => {
expect(results, 'to have length', 2);
});
});

it('ignores files in "node_modules" and ".git" by default', function() {
const testFile = path.join(this.tempDir, 'test.js');
copyFixture('__default__', testFile);
Expand Down