|
|
|
|
|
by anytime5704
707 days ago
|
|
This makes me feel better about wasting the last 2 days debugging a failed unit test that was due to duplicate dependencies (with different versions). expect(mockDynamoDBClient).toHaveReceivedAnyCommand(); // passes
expect(mockDynamoDBClient).toHaveReceivedCommand(UpdateCommand); // fails
Received number of calls: 2
Expected number of calls: >= 1
Expected command: UpdateCommand
Received commands:
- UpdateCommand
- UpdateCommand
I thought I was taking crazy pills. |
|
Sadly, the most robust solution is often to use duck typing, e.g. instead of checking if the error is an instance of ResourceNotFoundError, check if error.code equals "ResourceNotFound" which works even if there are multiple library versions present. This is especially the case if you're writing a library that might be provided an instance of an AWS SDK v3 client, as it could be a different version.
I've been doing this stuff for 20 years so I'm used to it, I just feel bad for the novices.