tuan231195 / jest-aws-sdk-mock

MIT License
5 stars 1 forks source link

Testing calls rather than return data #4

Open marknorrapscm opened 3 years ago

marknorrapscm commented 3 years ago

I like this package and want to use it, but after playing about with it I cannot get it to work with any of Jest's toHaveBeenCalled() assertions.

Rather than just testing return data, I want to test that the actual functions have been called. I can do this with my own mock of the AWS-SDK but using this pre-made one would save me considerable time. Something like this:

test("test return data", async () => {
    AWS.mock("CloudFront", "listDistributions", []);
    await getCloudfrontDistributions();
    expect(new AWS.CloudFront().listDistributions).toHaveBeenCalled();
});

Is this possible? If it is, and you can demo it to me, I will happily add to the README and submit a PR.