jest
jest copied to clipboard
add support for Explicit Resource Management to mocked functions
Summary
This implements #14294
Spied-on functions can now be instantiated with using instead of const and they will be restored once the current scope is left.
Test plan
I added a ~~test to jest-mock~~ an integration test.
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: phryneas / name: Lenz Weber-Tronic (82c82b16c8931317fe482945ae474c4bcf94ec02, f1ea1f708dab8bd3ae0da01435abc52a74819f38, a10c15184d8d0360cdbbbf0b5f93e23f0c4c272a, 7cfc9d00aabba2c306083b925d84a6af453c01de, b8e9f02fbfa6fc86517eef1360d9cff2d15ad2fb, fe13eeedad8a3f9ea25705c4f0de144258709f68, e5cf3d22f284255de4815015fd612f66ba8857e0, b117fade556b9083924a9a9d7059853f6813f605)
- :white_check_mark: login: SimenB / name: Simen Bekkhus (9ebd28671f2df4a14b5b4953620f95db8a902ba4, ce99d2dd7a01a206e69408efd1144b991f5a5290, 46031c12bf129d78edf50752b7611a815d157887, 832523f0a3740085b0d0babfa38c88be9782e1de, da7d505cab54304ab4af26ee460ae7b4c9d97d90, 37401b9c5391718e050b9430b19fed554533eb0e, 6c9f0e6e16bb0c92458366b42c2549d630254085)
Deploy Preview for jestjs ready!
| Name | Link |
|---|---|
| Latest commit | 6c9f0e6e16bb0c92458366b42c2549d630254085 |
| Latest deploy log | https://app.netlify.com/sites/jestjs/deploys/65d470979769800008716bad |
| Deploy Preview | https://deploy-preview-14895--jestjs.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Generally, I don't really know what to make of these node16 failures, so I'd be happy for any feedback. As this feature is not available there, is it sensible to skip the tests there?
As this feature is not available there, is it sensible to skip the tests there?
Yes. Usually tests are skipped, if some feature is not supported. The onNodeVersions() helper is used for that (look around for usage examples): https://github.com/jestjs/jest/blob/8bbe2a34a8a7979d71ece3fadc6006df3e607d9f/packages/test-utils/src/ConditionalTest.ts#L33-L35
It would be good to mention the feature in documentation. That is a good place to clear out the requirements like Node.js or TypeScript versions.
I've also added some docs. I hope the place works, and if you have any suggestions for better examples, I'm very open to feedback. Good docs examples are not my biggest strength :)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.