Closed swashcap closed 4 years ago
The types are not maintained in this repo (yet, at least) - this issue belongs in DefinitelyTyped.
I do agree it'd be nice, though! Please add a link in this issue when you create one over there
I made an issue here: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/41179
This issue 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.
š Feature Proposal
Support TypeScript 3.7's new assertion functions.
Motivation
Jest should support this TypeScript language feature to make authoring tests simpler.
Example
Let's say I have a function under test that returns a nullable value:
Currently, testing the results requires null checks for every assertion:
The first uses the
!
non-null operator, which opts out of type safety and can lead to confusing error reports. The second seems non-idiomatic: why not writeexpect(data).toBeTruthy()
?With TypeScript 3.7 you can now define Jest's global
expect
to behave this way:(Although typing w/ the Jest's chaining will be a bit more involved.)
Pitch
Why does this feature belong in the Jest core platform?
This feature request relates to assertions, which are at the core of Jest.