Replies: 1 comment 3 replies
-
|
I looks like a bit of edge case, but not sure. From a quick look, it would make more sense to do in the following order with "reset" then "mock". Would this work too or also broken? vi.resetModules();
vi.doMock("virtual:test", () => ({ getFirstNumber: () => 2 })); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using a discussion as I'm not sure yet if this is an expected change of behavior, a bug, or just me misusing an API.
In a test file, I have different
describeblocks where in each of them, I mock a virtual module, e.g. usingvi.doMock()and mock a function from that module making it return different values.I've carefully read the Vitest 4 migration guide, and specifically the section about "Changes to Mocking", but unless I'm missing something, I don't think any of the listed changes explain this behavior.
I've setup a minimal repro here where tests are failing due to unexpected values being returned. When running
pnpm add vitest@3in the same repo, all tests pass as expected.Thanks for any insights and your time 🙌
Beta Was this translation helpful? Give feedback.
All reactions