@@ -24,6 +24,8 @@ const SearchSource = require('./SearchSource');
24
24
const TestWatcher = require ( './TestWatcher' ) ;
25
25
const { KEYS , CLEAR } = require ( './constants' ) ;
26
26
27
+ const SNAPSHOT_EXTENSION = 'snap' ;
28
+
27
29
const watch = (
28
30
config : Config ,
29
31
pipe : stream$Writable | tty$WriteStream ,
@@ -43,12 +45,18 @@ const watch = (
43
45
let displayHelp = true ;
44
46
let searchSource = new SearchSource ( hasteContext , config ) ;
45
47
46
- hasteMap . on ( 'change' , ( { hasteFS, moduleMap} ) => {
47
- hasteContext = createHasteContext ( config , { hasteFS, moduleMap} ) ;
48
- currentPattern = '' ;
49
- isEnteringPattern = false ;
50
- searchSource = new SearchSource ( hasteContext , config ) ;
51
- startRun ( ) ;
48
+ hasteMap . on ( 'change' , ( { eventsQueue, hasteFS, moduleMap} ) => {
49
+ const hasOnlySnapshotChanges = eventsQueue . every ( ( { filePath} ) => {
50
+ return filePath . endsWith ( `.${ SNAPSHOT_EXTENSION } ` ) ;
51
+ } ) ;
52
+
53
+ if ( ! hasOnlySnapshotChanges ) {
54
+ hasteContext = createHasteContext ( config , { hasteFS, moduleMap} ) ;
55
+ currentPattern = '' ;
56
+ isEnteringPattern = false ;
57
+ searchSource = new SearchSource ( hasteContext , config ) ;
58
+ startRun ( ) ;
59
+ }
52
60
} ) ;
53
61
54
62
process . on ( 'exit' , ( ) => {
0 commit comments