I have some unit tests where I am using aws-sdk-client-mock-jest
to mock DynamoDB
operations. I am importing the following packages like so:
import "aws-sdk-client-mock-jest";
const {DynamoDBClient} = require("@aws-sdk/client-dynamodb");
const {QueryCommand} = require("@aws-sdk/lib-dynamodb");
const {mockClient} = require("aws-sdk-client-mock");
In my unit tests, I am using the mocks like this:
const ddbMock = mockClient(DynamoDBClient);
test("Received customer", async () => {
ddbMock.on(QueryCommand).resolves({
"name": "customer",
"data": "some data"
});
const db = new DbRepository();
const customer = await db.getCustomerAsync();
// some assertions
expect(customer).toHaveProperty("name", "customer");
});
However, when the toHaveProperty() is called an error is thrown which states: TypeError: this.customTesters is not iterable
What am I doing wrong here?
Any suggestions are welcome. Thanks!
I tried to use the expect library as mentioned here but that does not work.
My unit tests are JS files.