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: pass matcher context to asymmetric matchers #11926

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Oct 4, 2021

Summary

This exposes that asymmetric matchers are not called with this - which IMO is a bug. For now I've stuck a @ts-ignore there, but we should fix it

Asymmetric matchers were not called with matcher context - meaning they didn't have access to this.equals, this.utils etc..

First commit makes TypeScript highlight that as an error, second commit fixes passing this.

Test plan

Green CI

@SimenB SimenB changed the title fix: type RawMatcherFn with correct this fix: pass matcher context to asymmetric matchers Oct 4, 2021
const {pass} = matcher(
const {pass} = matcher.call(
this.matcherState,
Copy link
Member Author

@SimenB SimenB Oct 4, 2021

Choose a reason for hiding this comment

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

here's the fix - our own matchers "cheat" by not using this but rather importing equals etc directly

@codecov-commenter
Copy link

Codecov Report

Merging #11926 (010797a) into main (b9fc8ac) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11926      +/-   ##
==========================================
- Coverage   68.76%   68.75%   -0.01%     
==========================================
  Files         322      322              
  Lines       16591    16589       -2     
  Branches     4787     4786       -1     
==========================================
- Hits        11408    11406       -2     
  Misses       5151     5151              
  Partials       32       32              
Impacted Files Coverage Δ
packages/expect/src/asymmetricMatchers.ts 83.33% <100.00%> (ø)
packages/expect/src/jestMatchersObject.ts 82.85% <100.00%> (-0.48%) ⬇️
packages/expect/src/matchers.ts 97.86% <100.00%> (-0.01%) ⬇️

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 b9fc8ac...010797a. Read the comment docs.

@SimenB SimenB merged commit f13abff into jestjs:main Oct 5, 2021
@SimenB SimenB deleted the type-raw-matcher-fn branch October 5, 2021 11:41
@github-actions
Copy link

github-actions bot commented Nov 5, 2021

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 Nov 5, 2021
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.

3 participants