-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Clear and concise description of the problem
Hey,
(first of all congrats on the 4.0 release!)
I recently discovered browser mode, and I am trying to migrate our vitest projects from JSDom to using browser mode instead. migrating the locators is not too challenging, as we come from testing library, but fixing all the mocks is to be honest.
The existing documentation on mocks under browser mode that I am aware of is this: https://vitest.dev/guide/browser/#spying-on-module-exports
it is concise, but already very helpful, without it I would not properly know what was wrong with what was previously normally functioning vitest tests.
I am still running into quite some particularities/gotchas of running tests in browser mode, to the point I think it would help if there was some documentation or a guide describing (correct me if I am wrong of course):
- which parts of the vitest API no longer work
- how previous tests can influence wether
vi.mock('./module.js', { spy: true })no longer works because that module was imported without mocks before. (A different feature request is perhaps that this would throw an error if possible?). I think this comment also holds valuable information on this topic. - how caching of modules or instances of them seems to work differently.
- other things I am currently unaware of.
Suggested solution
A page in the documentation of vitest browser mode that explains the mentioned particularities of mocking in browser mode.
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.