Mocks are lost when reruning the tests in browser mode when using MSW #6633
Labels
feat: browser
Issues and PRs related to the browser runner
p3-minor-bug
An edge case that only affects very specific usage (priority)
Describe the bug
Whenever you mock a module in browser mode and rerun the tests, mocks are non longer effective (the original module is used instead).
EDIT: this issue only occurrs when the MSW worker is active... so I'm not sure if it's a bug or if there is an explanation for the behaviour.
Reproduction
msw
as dependency and initialize the worker script withpnpm exec init public --save
vitest-setup.ts
, start the worker withbeforeAll(async () => await worker.start());
mock-me.ts
file withexport default "original";
for instancevitest-setup.ts
, mock the module withvi.mock("./mock-me", () => ({ default: "mocked" }));
vitest
"mocked"
r
ora
in the terminal"original"
Repo: https://github.com/foxaltus/vitest-browser-mode-repro
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: