Matcher includes is not working in expectJsonSnapshot
See original GitHub issueDiscussed in https://github.com/pactumjs/pactum/discussions/98
<div type='discussions-op-text'>Originally posted by captaincc423 December 1, 2021 I’m trying to get some matchers to work in expectJsonSnapshot and I’m running into a few problems:
- I’m trying to use a variable variable with a string in an “includes()”, e.g.
"id": includes(response.body.id)
and it’s not working. It always says it doesn’t match.
Am I misusing these matchers?</div>
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
includes() not working in Internet Explorer - javascript
include () in javascript you can use this script: github-script-ie-include That converts automatically the include() to the match() function if it detects IE....
Read more >expectJsonSnapshot - PactumJS
The test will fail if the two snapshots do not match: either the change is unexpected, or the reference snapshot needs to be...
Read more >`include` matcher - RSpec Expectations 3.12 - Relish
`include` matcher. Use the include matcher to specify that a collection includes one or more expected objects. It succeeds if any object of...
Read more >Should You Use .includes or .filter to Check if An Array ...
My brain likes to solve the problem of determining whether an array contains an item by finding the matching items using .filter() ....
Read more >Jest Array/Object partial match with objectContaining and ...
expect has some powerful matcher methods to do things like the above ... for a new matcher proposal: github.com/facebook/jest/issues/3954 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, It’s true, is necessary evaluate the impact.
Another solution could be passing the functions as string in to include(), and use eval() o new Function()() for evaluate in to _validateJsonSnapshot(response) , for example:
OK, Interesting, I take your recommendation with strict comparison configurable and prepare a Pull Request! thanks