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

feat: add .toBeJsonMatching(expectation) matcher #481

Closed
wants to merge 2 commits into from

Conversation

Belema
Copy link

@Belema Belema commented Aug 2, 2022

What

This adds support for a new custom matcher .toBeJsonMatching(...).

Why

This matcher is useful when one wants to check that a function has been called with a JSON string that satisfies some constraints,

expect(fn).toHaveBeenCalledWith(
  expect.toBeJsonMatching({ key1: 'value1' })
);

Housekeeping

  • Unit tests
  • Documentation is up to date
  • No additional lint warnings
  • Typescript definitions are added/updated where relevant

@Belema Belema force-pushed the to-be-json-matching branch 5 times, most recently from 2dede58 to e05e2e4 Compare August 4, 2022 10:24
@SimenB
Copy link
Member

SimenB commented Feb 18, 2023

@Belema I like this - could you resolve the conflicts?

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2023

⚠️ No Changeset found

Latest commit: d2fdc8b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Belema
Copy link
Author

Belema commented Feb 18, 2023

@Belema I like this - could you resolve the conflicts?

@SimenB, I have just rebased the changes.

@codecov
Copy link

codecov bot commented Feb 18, 2023

Codecov Report

Merging #481 (d2fdc8b) into main (5b80ca8) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #481   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           73        74    +1     
  Lines          674       712   +38     
  Branches       290       304   +14     
=========================================
+ Hits           674       712   +38     
Impacted Files Coverage Δ
src/matchers/toBeJsonMatching.js 100.00% <100.00%> (ø)
src/matchers/toPartiallyContain.js 100.00% <100.00%> (ø)
src/utils/index.js 100.00% <100.00%> (ø)

@SimenB
Copy link
Member

SimenB commented May 23, 2023

Make sure to add a changeset so this triggers a release

@Belema
Copy link
Author

Belema commented May 23, 2023

Make sure to add a changeset so this triggers a release

@SimenB I have done so, and accidentally deleted my branch (which closed this PR). I have opened a new one #606 for it.

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

Successfully merging this pull request may close these issues.

2 participants