feat: Explicit Resource Management support in mocked functions#7927
feat: Explicit Resource Management support in mocked functions#7927sheremet-va merged 6 commits intovitest-dev:mainfrom
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Thanks! I think this is nice to have. Vitest should already support using at least on typescript out of the box since esbuild transpiles it #4409, so you can probably add a test with using like
vitest/test/core/test/esnext.test.ts
Lines 15 to 24 in 30b709c
|
This looks good to me, but seems like tests are failing (ignore the browser ones) |
|
never mind - I see that the core tests are failing as well |
|
(non-browser) tests are fixed - the dispose was holding onto the function reference instead of using the key we can spy on. |
Description
Support explicit resource management with mocked functions, meaning mockRestore can be called automatically once scope is exited.
This is very convenient, but also good for Jest parity - Jest added it here jestjs/jest#14895 and released in v30.0.0-alpha.3.
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:.