You should be familiar with the AWS.Request object, because if your code needs to set special expectations for.For nested clients like, you can mock methods like this: AWS.spyOn('DynamoDB.DocumentClient', 'get').If you try to mock a method twice, you will get an error.'use strict' const AWS = require ( 'aws-sdk' ) describe ( 'getting things', ( ) => ) Some notes Here is an example function that maybe you would like to test. This clears all your mocks and should be used in afterEach() functions. eachPage() caller after sending non-error pages. If any of the pages are an Error object, then that error will be returned to the. The pages argument is required, and must be an array representing the pages that the code will observe during the test. This time, it anticipates that your code under test will use the. promise() will resolve with that thing.ĪWS.spyOnEachPage(service, method, pages)Īlso returns a Jest mock function for an AWS SDK method call that supports pagination, like s3.listObjectsV2(). If you provide any other thing as response, the.If you provide an Error object as response, the.promise() will resolve with an empty object. If you do not provide a response, the. However, it anticipates that your code under test will use the. mockReturnValue() by setting it on the mock function in your test.ĪWS.spyOnPromise(service, method, response)Īgain, returns a Jest mock function for an AWS SDK method call like s3.getObject(). Returns a Jest mock function for an AWS SDK method call like s3.getObject(). exports = require ( ) The mocking methods it provides
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |