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(expect): move typings of .not, .rejects and .resolves modifiers outside of Matchers interface #12346

Merged
merged 2 commits into from
Feb 9, 2022
Merged

fix(expect): move typings of .not, .rejects and .resolves modifiers outside of Matchers interface #12346

merged 2 commits into from
Feb 9, 2022

Conversation

mrazauskas
Copy link
Contributor

Summary

Current expect typings allow to write expectations like this: expect(1).not.not.resolves.rejects.not.rejects.toBe(2). Looks funny. That’s because .not, .rejects and .resolves lives inside Matchers interface.

I looked at @types/jest. Their types work correctly, but it was hard to read them. My version is perhaps less perfect, but I think it is easier to read.

Test plan

Type tests which will fail on main are added. All should pass in CI.

not: Omit<AsymmetricMatchers, 'any' | 'anything'>;
};

export interface AsymmetricMatchers {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were not exported before. I think it might be good idea to allow extending these too.

@codecov-commenter
Copy link

Codecov Report

Merging #12346 (c6d0e1e) into main (7f7b3fb) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12346      +/-   ##
==========================================
- Coverage   66.97%   66.93%   -0.04%     
==========================================
  Files         329      329              
  Lines       17335    17344       +9     
  Branches     5061     5061              
==========================================
  Hits        11610    11610              
- Misses       5693     5702       +9     
  Partials       32       32              
Impacted Files Coverage Δ
packages/jest-types/__typetests__/expect.test.ts 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f7b3fb...c6d0e1e. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Yay! Especially love the tests that comes with these PRs, can't thank you enough 👍

@SimenB SimenB merged commit e9eced4 into jestjs:main Feb 9, 2022
@mrazauskas mrazauskas deleted the fix-InverseMatchers-PromiseMatchers branch February 9, 2022 20:13
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants