test(project): Mock @parcel/watcher in BuildServer integration tests#1406
Open
matz3 wants to merge 2 commits into
Open
test(project): Mock @parcel/watcher in BuildServer integration tests#1406matz3 wants to merge 2 commits into
matz3 wants to merge 2 commits into
Conversation
Replace the real file watcher with an in-process esmock of @parcel/watcher so tests can fire watcher events deterministically instead of waiting on OS-level event delivery. The previous setup relied on a real watcher and padded against its latency with setTimeout(500) after each fs.appendFile/writeFile. Beyond the flakiness, @parcel/watcher fails to subscribe inside sandboxed environments where FSEvents/inotify access is restricted, blocking the entire suite. The mock keeps WatchHandler and BuildServer paths under test (only parcelWatcher.subscribe is replaced) and exposes FixtureTester.fireWatcherEvent for synchronous event delivery. Per-source-line coverage is reduced as no 'create' event is fired anymore which then does not cover _projectResourceChanged with fileAddedOrRemoved=true. The 'create' event was only fired as a side-effect because the files under test are copied into a tmp directory right before the test runs. Explicit tests for the create and delete events should be added to cover this code path.
Add an integration test that explicitly fires 'create' and 'delete' watcher events through the @parcel/watcher mock to cover the fileAddedOrRemoved=true branch in BuildServer _projectResourceChanged. Previously this branch was only hit as a side-effect of the fixture copy running after the watcher subscribed; with the mock, no such side-effect exists and the path needs explicit coverage.
eedf745 to
e7645d5
Compare
RandomByte
approved these changes
Jun 8, 2026
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.
Also includes follow-up commit:
test(project): Cover create and delete watcher events in BuildServer