Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for Explicit Resource Management to mocked functions #14895
add support for Explicit Resource Management to mocked functions #14895
Changes from 1 commit
f1ea1f7
7cfc9d0
a10c151
e5cf3d2
82c82b1
fe13eee
b117fad
b8e9f02
46031c1
37401b9
9ebd286
ce99d2d
832523f
da7d505
6c9f0e6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit weird, and the result of #14888 - usually, it should be possible to polyfill
Symbol.dispose
in any possible way, e.g. by doingSymbol.dispose ??= Symbol.for('dispose')
, but because of #14888 it needs to explicitly be polyfilled withSymbol.for('nodejs.dispose')
.I'm not sure if that change over there was a good idea, especially because that polyfill doesn't seem to be available in all scopes (that's why we need to polyfill here in the first place).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that also explains the failing node16 tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what the symbol is in a nodejs app, tho. so why would it be an issue?
But if we instead move the test to an e2e test as mentioned elsewhere, then we could just skip that tests on node versions which don't support it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a bit irritating to me first because jest picks up
Symbol.dispose
asSymbol.for('nodejs.dispose')
, while in the test itself wasundefined
, so it needed to be polyfilled to the same value (while in a normal application, you can polyfill it as pretty much anything and don't need to match the "outside runtime").But I guess it makes sense that
jest
itself might see something different than the JestEnvironment itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a common usage:
using mockedLog = jest.spyOn(console, 'log');
is only mocked inside of the current scope, and as soon as the block is left, the mock is restored.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this with the inline
<reference lib="ESNext.Disposable" />
?