Skip to content
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

Use expect 28 style typescript module augmentation #483

Closed
wants to merge 1 commit into from

Conversation

IanVS
Copy link
Contributor

@IanVS IanVS commented Oct 6, 2022

What:

This adds a types export for the package, using jest 28's recommended way to augment expect: https://jestjs.io/blog/2022/04/25/jest-28#expect

This might be a breaking change for users on jest 27 or below and using typescript.

Why:

I want to update @storybook/expect to 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 expect package, using the types from definitely-typed (instead of trying to move them into this package for now).

Checklist:

  • Documentation
  • Tests
  • Updated Type Definitions
  • Ready to be merged

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 using jest globals, but are using expect directly.

Note: I also had to tweak the eslint config a little bit, so that the @typescript-eslint rules stopped failing and would let the precommit hook succeed. Buuuut, it looks like that's failing CI. Maybe a maintainer can get main working correctly with eslint, and I can rebase this on top?

@IanVS
Copy link
Contributor Author

IanVS commented Oct 6, 2022

@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).

@github-actions
Copy link

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant