-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for ignoring unknown keys in JSON asserts (#2303)
* Support for ignoring unknown keys in JSON asserts Added new matchers `shouldEqualJsonIgnoringUnknown` and `shouldNotEqualJsonIgnoringUnknown`. Supports for specifying all other flags that the previous json matcher supported. The existing compare method already supported the use-case quite easily, and had good error messages for possible validation errors. Unknown keys can only exist in object nodes. The scenarios currently covered by tests are: * Actual contains a key not specified in expected - key is ignored * Actual contains a key specified in expected - key is compared * Actual is missing a key specified in expected - matcher error occurs Since comparison happens recursively, I also added tests to make sure the ignoring is in effect deeper in the structure as well. * Renamed assertion and flag * Updated docs * Updated names according to PR discussion * Fix merge issue Co-authored-by: Sam Sam <sam@sksamuel.com>
- Loading branch information
Showing
6 changed files
with
304 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.