-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Don't rebuild packages when test file gets updated #11799
Comments
@gziolo Hi greg // Exclude test files and deceitful source-like files, such as editor swap files.
const isSourceFile = ( filename ) => {
return ! /\/test\//.test( filename ) && /.\.(js|scss)$/.test( filename );
}; You mention that the message printed on the console is also wrong.But I do not know how to reproduce this error. When I run |
@Jackie6, it's almost true. There are some exceptions with how tests are discovered. There are 3 patterns which can be used:
That's surprising, this command starts watch mode so it should trigger changes any time any code is updated inside packages folder according to the rule you are about to update. |
@gziolo Hi Greg. Thank you for pointing out the test match pattern. gutenberg/packages/jest-preset-default/jest-preset.json Lines 17 to 21 in 7779964
So I translate the patterns to regex. I have created a pull request to fix this issue. The modified code is as follows: // 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 ! [/\/(__tests__|test)\/.+.js$/, /.\.(spec|test)\.js$/].some( regex => regex.test( filename ) ) && /.\.(js|scss)$/.test( filename );
}; |
As discussed on Slack with @youknowriad, it looks like our watch script for packages is too greedy and rebuilds them when non-production code gets updated: https://wordpress.slack.com/archives/C5UNMSU4R/p1542097900320400
![screen shot 2018-11-13 at 09 30 05](https://user-images.githubusercontent.com/699132/48400827-bcad1280-e727-11e8-928b-acc194234c14.png)
We should exclude test files from the list of files which trigger rebuild of the packages. It looks like we already exclude some types of files, so it might be possible to extend the following function:
gutenberg/bin/packages/watch.js
Lines 25 to 28 in 1de0887
By the way, it looks like the message printed on the console is also wrong. I didn't rename any file but I added a few modifications.
The text was updated successfully, but these errors were encountered: