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

fix: matchers type is making the global expect unsafe #513

Merged
merged 6 commits into from Aug 18, 2023
Merged

fix: matchers type is making the global expect unsafe #513

merged 6 commits into from Aug 18, 2023

Conversation

kryops
Copy link
Contributor

@kryops kryops commented Aug 16, 2023

What:

Port of DefinitelyTyped/DefinitelyTyped#66247, after the types moved here in #511

Why:

See DefinitelyTyped/DefinitelyTyped#64858

How:

Moved the Record<string, any> constraint to the matchers export only, and removed it from the interface that augments the global Jest matchers.

Checklist:

  • Documentation N/A
  • Tests
  • Updated Type Definitions
  • Ready to be merged

I added a file with the TypeScript test cases from DefinitelyTyped, as they safeguard that the types should work correctly and prevent this issue from regressing. If they shouldn't be part of this repo, feel free to drop the last commit.

@jgoz
Copy link
Collaborator

jgoz commented Aug 17, 2023

This is great, thank you for porting over the type tests. I'm going to test out these changes in my test repos tomorrow and then merge

@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Merging #513 (d581e7d) into main (4b764b9) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #513   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines          664       664           
  Branches       251       251           
=========================================
  Hits           664       664           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@jgoz jgoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kryops. I pushed a couple of commits to make this compatible with all 3 test platforms that we support and split/duplicated the type tests as such. It actually helped catch an issue with the @jest/globals interface definition.

Also enabled running the type tests in CI.

@jgoz jgoz merged commit bdb34f1 into testing-library:main Aug 18, 2023
7 checks passed
@github-actions
Copy link

🎉 This PR is included in version 6.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nickmccurdy
Copy link
Member

@all-contributors add @kryops for bug code test

@allcontributors
Copy link
Contributor

@nickmccurdy

I've put up a pull request to add @kryops! 🎉

@gnapse
Copy link
Member

gnapse commented Feb 1, 2024

@all-contributors add @kryops for bug code test

Copy link
Contributor

@gnapse

I've put up a pull request to add @kryops! 🎉

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.

None yet

4 participants