-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat(@jest/environment, jest-runtime): allow requireActual
and requireMock
to take a type argument
#13253
Conversation
requireActual: this.requireActual.bind(this, from), | ||
requireMock: this.requireMock.bind(this, from), | ||
requireActual: moduleName => this.requireActual(from, moduleName), | ||
requireMock: moduleName => this.requireMock(from, moduleName), |
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.
Is this fine? Not sure I understand what bind
does here. Rework it, because I couldn’t find a clean way to return T
through bind
. Only work around was though casting, but this way it looked cleaner. All test are passing locally, let’s see what CI thinks.
getRandom: jest.fn().mockReturnValue(10), | ||
getRandom: jest.fn(() => 10), |
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 way it doesn’t require additional typings in TS example. Less noise.
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 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. |
From #13199 (comment)
Summary
Currently
jest.requireActual
andjest.requireMock
returnunknown
. It is possible to useas typeof import('../someModule')
to cast the return value. At the same time, it is somewhat nicer to do this via generic type argument:Test plan
Type tests are added.