-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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 the Config
type test to TSTyche
#14687
chore: migrate the Config
type test to TSTyche
#14687
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
testMatch: [ | ||
'**/__typetests__/**/*.test.ts', | ||
'!**/packages/jest-types/__typetests__/config.test.ts', | ||
], |
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 looks clumsy for now, but the diff is more readable.
expect(config).type.toBeAssignable({ | ||
fakeTimers: { | ||
advanceTimers: true, |
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.
Comparing inferred type with and inferred type. Looks simple, but that was not possible with tsd
.
Very exciting stuff! Would it be possible to create a Jest runner for this instead of using the CLI directly? I really like just using The tests themselves look awesome 👍 |
In the beginning this was a runner, but Also how to do And so on. It was much more job to build a stand alone CLI tool, but that solved many problems. |
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.
back from the dead 😅 sorry about the slow response.
Happy to move forward with this if you think the tests are more powerful 👍
Can you update to the latest version?
'Date' as const, | ||
'hrtime' as const, | ||
'nextTick' as const, | ||
'performance' as const, | ||
'queueMicrotask' as const, | ||
'requestAnimationFrame' as const, | ||
'cancelAnimationFrame' as const, | ||
'requestIdleCallback' as const, | ||
'cancelIdleCallback' as const, | ||
'setImmediate' as const, | ||
'clearImmediate' as const, | ||
'setInterval' as const, | ||
'clearInterval' as const, | ||
'setTimeout' as const, | ||
'clearTimeout' as const, |
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.
why do we have to as const
them all? can we just do that for the entire array instead?
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.
as const
on the whole array results in different type. In that case this would be a readonly tuple of string literal types, but the option expects an array of string literal types. The test is not passing. (To make the test pass, it is enough to have doNotFake: [...doNotFake]
, but that looks odd.)
I work on one idea which could improve this in the future. For now this is an assignability test and that is how it currently works. I mean, it works and it tests the right thing! That is very good for the first release of TSTyche. And future will bring in improvements for sure.
Done. The latest version of TSTyche is pinned. It has only few minor improvements. By the way, Recently I added Not sure which strategy is better. Perhaps CI could run with |
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 is migrating the
Config
type test to TSTyche.Some two years ago I thought to develop a type testing tool from scratch: jest-community/jest-runner-tsd#32.
Honestly excited to open the very first PR to see TSTyche in action.
Few notable features of TSTyche:
tstyche --target 5.0,latest
;test()
anddescribe()
which support.only
,.skip
run mode flags;expect
style assertions to can compare two types, or two expressions, or an expression with a type;I decided to publish a beta release first to check how well it works with larger code bases in CI. Otherwise the type testing assertions are stable, well tested, and everything thoroughly documented at https://tstyche.org.
Test plan
Green CI.