Skip to content

test(project): Mock @parcel/watcher in BuildServer integration tests#1406

Open
matz3 wants to merge 2 commits into
mainfrom
test/mock-parcel-watcher
Open

test(project): Mock @parcel/watcher in BuildServer integration tests#1406
matz3 wants to merge 2 commits into
mainfrom
test/mock-parcel-watcher

Conversation

@matz3

@matz3 matz3 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Also includes follow-up commit: test(project): Cover create and delete watcher events in BuildServer

@matz3 matz3 requested a review from a team June 8, 2026 15:52
matz3 added 2 commits June 8, 2026 18:19
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.
@matz3 matz3 force-pushed the test/mock-parcel-watcher branch from eedf745 to e7645d5 Compare June 8, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants