-
-
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
chore: migrate jest-mock
type tests to TSTyche
#14884
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -144,7 +144,10 @@ function typeTests() { | |||
|
|||
verifyInstalledTypescript(); | |||
|
|||
execa.sync('yarn', ['test-types'], {cwd, stdio: 'inherit'}); | |||
execa.sync('yarn', ['test-ts', '--selectProjects', 'type-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.
Overlooked it before. Current script runs TSTyche as well. This is just waste of time, because yarn tstyche --target 5.0,current
already tested on TypeScript 5.0.
((a: string, b?: number | undefined) => boolean) | undefined | ||
>(); | ||
|
||
expect(mockFn.getMockImplementation('some-mock')).type.toRaiseError(); |
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.
.toRaiseError()
check the error message, but I avoid these in this PR. 1. This is exactly what was tested before, so there is no regression. 2. The intention of this test is not about error message, the goal is to test this:
expect(mockFn.getMockImplementation).type.not.toBeCallableWith('some-mock');
The ability matchers, like matchers like .toBeCallableWith()
, should ship with TSTyche 2. So I will use them here later.
mockFunction.mockImplementation((a: boolean, b?: number) => true), | ||
).type.toRaiseError(); | ||
|
||
expect(someFunction).type.toBeAssignable(mockFunction); |
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.
Types of two expressions compared. That’s an improvement. Nice to see!
|
||
// FunctionLike | ||
test('MethodKeys', () => { | ||
expect<MethodLikeKeys<SomeClass>>().type.toEqual<'methodA' | 'methodB'>(); |
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.
Two types are compared directly. No need of declare const
in utility type tests. Also nice improvement.
|
||
test('models typings of mocked function', () => { | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
expect(fn()).type.toMatch<Function>(); |
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.
.toMatch()
instead of assignability. This checks that fn()
extends from the Function
type. Perhaps .toExtend()
would be better name for this matcher. In a way it is almost the same.
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.
great stuff as always. thanks!
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. |
Summary
This PR migrates
jest-mock
type tests to TSTyche. The diff is hm.. There is no diff actually, these look like newly added files. Not sure if this is good for review. Or is that fine?Test plan
The type tests should pass.