fix(core): restore async doMock factory and doUnmock recovery#998
fix(core): restore async doMock factory and doUnmock recovery#998
Conversation
Deploying rstest with
|
| Latest commit: |
ae57319
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f2a72577.rstest.pages.dev |
| Branch Preview URL: | https://fix-mock-runtime-async-dounm.rstest.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae57319d63
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (isPromise(res)) { | ||
| __webpack_module__.exports = res; | ||
| return; |
There was a problem hiding this comment.
Support async rs.mock factories for static named imports
When modFactory() returns a Promise, this path assigns that Promise to module.exports and returns before any ESM export getters are defined. In hoisted rs.mock(...) flows that use static named imports (the common rs.mock pattern), bindings like import { increment } resolve to undefined and fail at call time (... is not a function), so async factory support is still broken for that usage even though the API/docs now advertise Promise-returning factories.
Useful? React with 👍 / 👎.
Summary
v0.8.2:rs.doMock(..., async () => ...)could expose broken exports because Promise factory results were not handled in the runtime module factory pathrs.doMock()calls could overwrite original module snapshots, sors.doUnmock()no longer restored the true original implementatione2e/mock/tests/doMockAsyncFactory.test.tse2e/mock/tests/doUnmockRestoreOriginal.test.tsrs.mock/rs.doMockfactory type signatures to align with Promise-returning factory supportFlow (Before vs After)
Related