Jest matchers don't allow use of jest submatchers for input object filtering
See original GitHub issueChecklist
- I have read Caveats documentation and didn’t find a solution for this problem there.
Bug description
The Jest matchers added here still use the sinon call matching logic here so jest submatchers don’t work. For example, I would expect this code to work:
expect(mock).toHaveReceivedCommandWith(QueryCommand, {
TableName: expect.stringMatching(/^foo/)
});
Instead I get the following error:
Error: Expected DynamoDBDocumentClient to receive "QueryCommand" with {"TableName": StringMatching /^foo-/}
DynamoDBDocumentClient received "QueryCommand" 0 times
Calls:
1. QueryCommand: {"ExpressionAttributeValues": {":guid": "guid"}, "KeyConditionExpression": "id = :guid", "Limit": 1, "ScanIndexForward": false, "TableName": "foo-undefined"}
Environment
- Node version: 14.19.3
- Testing lib and version: Jest
- Typescript version: 4.2.4
- AWS SDK v3 Client mock version: 1.0.0
- AWS JS SDK libs and versions:
- @aws-sdk/client-dynamodb: 3.49.0
- @aws-sdk/lib-dynamodb: 3.49.0
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Using Matchers
Using Matchers. Jest uses "matchers" to let you test values in different ways. This document will introduce some commonly used matchers.
Read more >The hidden power of Jest matchers | by Boris - Medium
1. Match calls with function in arguments. Imagine, that you need to test that some API method was called properly. When all method...
Read more >Jest Array/Object partial match with objectContaining and ...
It's possible to do partial matches on Arrays and Objects in Jest using expect.objectContaining and expect.arrayContaining .</
Read more >Add matcher to assert object keys · Issue #2143
Add a matcher to assert a given object keys exists. I've read the docs and didn't find any matcher for this. Something with...
Read more >Jest: expect object not to have property - javascript
objectContaining() . This approach works fine but has one unfortunate edge case: It matches when the property exists, but is undefined or null...
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
Thank you, I will check what’s the standard way of achieving this with custom Jest matchers and make an update.
#101