fix: fix re-mocking virtual module#9748
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| id, | ||
| url: id, | ||
| id: resolvedMock.id, | ||
| url: resolvedMock.url, |
There was a problem hiding this comment.
For the case of virtual module, here we previously had id = /@id/virtual-module (aka "url") as module runner fetchModule result, which then leaded to evaluatedModuleNode.id = mock:/@id/virtual-module during later mock interception.
However, when invalidating mock for next doMock calls, we use resolveId of virtual-module and it tries to invalidate mock:virtual-module. This inconsistency makes invalidation to miss.
What this resolvedMock case should do instead is to return id as resolvedId of mocked module, which is already available as resolvedMock.id, so that is the solution here.
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.