When some static key doesn't match, Object matcher fails all keys that should match to regexp
See original GitHub issue🐛 Bug Report
When some static key doesn’t match, Object matcher fails all keys that should match to regexp
To Reproduce
Run the following test:
test("asdf", async () => {
const actual = {
a: "a_value",
b: "b_value",
c: "c_value"
}
expect(actual).toMatchObject({
a: expect.stringMatching("[a-z]_value"),
b: "b_value",
})
expect(actual).toMatchObject({
a: expect.stringMatching("[a-z]_value"),
b: "B_VALUE",
})
})
Actual behavior
Matcher reports keys ‘a’ and ‘b’ as mismatched:
Expected value to match object:
{"a": StringMatching /[a-z]_value/, "b": "B_VALUE"}
Received:
{"a": "a_value", "b": "b_value", "c": "c_value"}
Difference:
- Expected
+ Received
Object {
- "a": StringMatching /[a-z]_value/,
- "b": "B_VALUE",
+ "a": "a_value",
+ "b": "b_value",
}
Expected behavior
Only ‘b’ key is reported as failed:
Object {
- "b": "B_VALUE",
+ "b": "b_value",
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
RegExp - JavaScript - MDN Web Docs - Mozilla
Chrome Edge
RegExp Full support. Chrome1. Toggle history Full support. Edge12. Toggle history
@@match Full support. Chrome50. Toggle history Full support. Edge13. Toggle history
@@matchAll Full...
Read more >4. Pattern Matching with Regular Expressions - Java ... - O'Reilly
You can then select Match, Find, or Find All. Match means that the entire string must match the regex, and Find means the...
Read more >Regex Pattern to Match, Excluding when... / Except between
Let's start with some background. First off, this is an excellent question. There are often questions about matching certain patterns except in certain...
Read more >Python Regex: re.search() VS re.findall() - GeeksforGeeks
re.search() method either returns None (if the pattern doesn't match), or a re.MatchObject that contains information about the matching part ...
Read more >Argument Validation — Mockery Docs 1.0-alpha documentation
Such argument matching is done on a “best fit” basis. ... By using Hamcrest, Mockery does not need to duplicate Hamcrest's already impressive...
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
This one is quite annoying since it’s hiding real problems in the output.
This issue 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.