test(search-api-graphql): mock the unloadable Prettier peer in its own file - #761
Open
ddeboer wants to merge 1 commit into
Open
test(search-api-graphql): mock the unloadable Prettier peer in its own file#761ddeboer wants to merge 1 commit into
ddeboer wants to merge 1 commit into
Conversation
…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.
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.
printSchemaModuleSdl > names the optional Prettier peer when it cannot be loadedfails on CI while passing locally – it took down the run onbf2dda0(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.doMockonly reaches a module imported after it, andvi.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.tswith a hoistedvi.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.