How to use the spyOn function from aws-sdk
Find comprehensive JavaScript aws-sdk.spyOn code examples handpicked from public code repositorys.
57 58 59 60 61 62 63 64 65 66
describe('getting things', () => { afterEach(() => AWS.clearAllMocks()); it('returns the thing', async () => { const get = AWS.spyOn('S3', 'getObject').mockReturnValue({ promise: () => Promise.resolve('foo') }); const thing = await getThing();
3
19
79
+ 11 other calls in file
GitHub: mapbox/aws-sdk-jest
36 37 38 39 40 41 42 43 44
expect(AWS.S3).toHaveBeenCalledWith({ region: 'ab-cdef-1' }); expect(get).toHaveBeenCalledWith({ Bucket: 'my', Key: 'thing' }); }); it('clears mocks', async () => { AWS.spyOn('S3', 'putObject'); const s3 = new AWS.S3(); expect(jest.isMockFunction(s3.putObject)).toEqual(true);
3
19
79
+ 19 other calls in file
51 52 53 54 55 56 57 58 59 60
}, 0) return self } const baseGet = () => AWS.spyOn('S3', 'getObject').mockImplementation(baseGetImplementation) afterEach(() => { spyLog.mockClear() spyError.mockClear()
2
10
3
+ 3 other calls in file
aws-sdk.S3 is the most popular function in aws-sdk (7245 examples)