Skip to content

test(search-api-graphql): mock the unloadable Prettier peer in its own file - #761

Open
ddeboer wants to merge 1 commit into
mainfrom
test/isolate-unloadable-prettier-peer
Open

test(search-api-graphql): mock the unloadable Prettier peer in its own file#761
ddeboer wants to merge 1 commit into
mainfrom
test/isolate-unloadable-prettier-peer

Conversation

@ddeboer

@ddeboer ddeboer commented Aug 21, 2026

Copy link
Copy Markdown
Member

printSchemaModuleSdl > names the optional Prettier peer when it cannot be loaded fails on CI while passing locally – it took down the run on bf2dda0 (main) and is currently blocking #758, a lockfile-only bump that cannot have caused it.

The case shared a file with the tests that format for real, so by the time it ran, the real Prettier had already been pulled into the module graph. vi.doMock only reaches a module imported after it, and vi.resetModules() does not evict an optional peer Node has already resolved, so whether the mock applied came down to module-graph ordering – which differs between a cold and a warm run.

It now lives in print-sdl-without-prettier.test.ts with a hoisted vi.mock('prettier'). Vitest gives each test file its own process, so the peer is unloadable from the first import onwards and nothing has to be unwound afterwards.

No production code changes; coverage is unchanged.

…n file

- Move the unloadable-peer case out of print-sdl.test.ts, where it ran
  after tests that format for real and so depended on module-graph
  ordering: doMock only reaches a module imported after it, and
  resetModules does not evict an optional peer Node has already resolved.
- Mock prettier with a hoisted vi.mock in the new file, so the peer is
  unloadable from the first import onwards and each file keeps its own
  process.
- Drop the afterEach that only existed to unwind that mock.
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.

1 participant