diff --git a/bin/packages/watch.js b/bin/packages/watch.js index fce8a6beedb977..dcbacb81d671e3 100644 --- a/bin/packages/watch.js +++ b/bin/packages/watch.js @@ -23,9 +23,11 @@ const exists = ( filename ) => { return false; }; -// Exclude deceitful source-like files, such as editor swap files. +// Exclude test files including .js files inside of __tests__ or test folders +// and files with a suffix of .test or .spec (e.g. blocks.test.js), +// and deceitful source-like files, such as editor swap files. const isSourceFile = ( filename ) => { - return /.\.(js|scss)$/.test( filename ); + return ! [ /\/(__tests__|test)\/.+.js$/, /.\.(spec|test)\.js$/ ].some( ( regex ) => regex.test( filename ) ) && /.\.(js|scss)$/.test( filename ); }; const rebuild = ( filename ) => filesToBuild.set( filename, true );