test: avoid intermittent failure of test.watcher.js#3695
Open
Rob--W wants to merge 1 commit intomozilla:masterfrom
Open
test: avoid intermittent failure of test.watcher.js#3695Rob--W wants to merge 1 commit intomozilla:masterfrom
Rob--W wants to merge 1 commit intomozilla:masterfrom
Conversation
The "changes if the watched file is touched" test failed frequently when
I ran it, due to the file change not having been detected. This is
because the `whenFilesChanged` promise has not resolved when the
hardcode test timeout of 500 ms was reached.
Bumping that 500 to 1000 solves the issue.
The "does not change if watched file is not touched" test is directly
impacted by this timeout change, because it waits for that time before
checking the result. To avoid this, schedule the setup of that test
earlier, so that it runs in parallel with the other test.
Before (2 seconds and intermittent failures):
```
✔ watches for changes in the sourceDir (1065ms)
--watch-file option is passed in
✔ changes if the watched file is touched (514ms)
✔ does not change if watched file is not touched (514ms)
```
After (2 seconds and no intermittent failure):
```
watcher
✔ watches for changes in the sourceDir (1078ms)
--watch-file option is passed in
✔ does not change if watched file is not touched (setup)
✔ changes if the watched file is touched (519ms)
✔ does not change if watched file is not touched (await) (498ms)
```
(without the parallelization trick, it would have taken 2.5 seconds)
Rob--W
commented
Apr 25, 2026
| resolve(assertParams); | ||
| }, 500), | ||
| ), | ||
| new Promise((resolve) => setTimeout(resolve, 1000)), |
Member
Author
There was a problem hiding this comment.
This 500 to 1000 change was the only necessary change of this whole code block here. However, I moved the old code around a little bit to increase the readability (making it obvious that whenFilesChanged is racing against a timer and that everything else is identical).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The "changes if the watched file is touched" test failed frequently when I ran it, due to the file change not having been detected. This is because the
whenFilesChangedpromise has not resolved when the hardcode test timeout of 500 ms was reached.Bumping that 500 to 1000 solves the issue.
The "does not change if watched file is not touched" test is directly impacted by this timeout change, because it waits for that time before checking the result. To avoid this, schedule the setup of that test earlier, so that it runs in parallel with the other test.
Before (2 seconds and intermittent failures):
After (2 seconds and no intermittent failure):
(without the parallelization trick, it would have taken 2.5 seconds)