Use expect 28 style typescript module augmentation#483
Closed
IanVS wants to merge 1 commit intotesting-library:mainfrom
Closed
Use expect 28 style typescript module augmentation#483IanVS wants to merge 1 commit intotesting-library:mainfrom
IanVS wants to merge 1 commit intotesting-library:mainfrom
Conversation
Contributor
Author
|
@nickmccurdy @gnapse I'd love to hear what y'all think of this, or if you have any other ideas of how to handle types for those of us not using jest globally. (e.g. #427). |
4 tasks
|
🎉 This issue has been resolved in version 6.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What:
This adds a
typesexport for the package, using jest 28's recommended way to augmentexpect: https://jestjs.io/blog/2022/04/25/jest-28#expectThis might be a breaking change for users on jest 27 or below and using typescript.
Why:
I want to update
@storybook/expectto use jest 28, but currently, due to the typescript changes in jest 28, the types from jest-dom are broken.I took a look at a few issues in this repo, including #426, #314, and #457, and I think I'm not alone in having issues with jest 28 and types.
How:
This augments the
expectpackage, using the types from definitely-typed (instead of trying to move them into this package for now).Checklist:
I'm opening this up for discussion. I tested this approach out in my own project, and it works correctly when I also add an
import '@testing-library/jest-dom';statement in@storybook/expect. I wanted to see if the maintainers of this repo would consider making a breaking change to support jest 28+, or if you have any other ideas of how to handle types for projects which aren't usingjestglobals, but are usingexpectdirectly.Note: I also had to tweak the eslint config a little bit, so that the
@typescript-eslintrules stopped failing and would let the precommit hook succeed. Buuuut, it looks like that's failing CI. Maybe a maintainer can getmainworking correctly with eslint, and I can rebase this on top?