Skip to content

Commit

Permalink
Filter snap file changes in watch mode (#2833)
Browse files Browse the repository at this point in the history
* Filter snap file changes in watch mode

* Change onlySnapFileEvents to hasOnlySnapshotChanges
  • Loading branch information
rogeliog authored and cpojer committed Feb 9, 2017
1 parent 204e46c commit 29c7980
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const SearchSource = require('./SearchSource');
const TestWatcher = require('./TestWatcher');
const {KEYS, CLEAR} = require('./constants');

const SNAPSHOT_EXTENSION = 'snap';

const watch = (
config: Config,
pipe: stream$Writable | tty$WriteStream,
Expand All @@ -43,12 +45,18 @@ const watch = (
let displayHelp = true;
let searchSource = new SearchSource(hasteContext, config);

hasteMap.on('change', ({hasteFS, moduleMap}) => {
hasteContext = createHasteContext(config, {hasteFS, moduleMap});
currentPattern = '';
isEnteringPattern = false;
searchSource = new SearchSource(hasteContext, config);
startRun();
hasteMap.on('change', ({eventsQueue, hasteFS, moduleMap}) => {
const hasOnlySnapshotChanges = eventsQueue.every(({filePath}) => {
return filePath.endsWith(`.${SNAPSHOT_EXTENSION}`);
});

if (!hasOnlySnapshotChanges) {
hasteContext = createHasteContext(config, {hasteFS, moduleMap});
currentPattern = '';
isEnteringPattern = false;
searchSource = new SearchSource(hasteContext, config);
startRun();
}
});

process.on('exit', () => {
Expand Down

0 comments on commit 29c7980

Please sign in to comment.