How to use the clearAllMocks function from aws-sdk
Find comprehensive JavaScript aws-sdk.clearAllMocks code examples handpicked from public code repositorys.
54 55 56 57 58 59 60 61 62 63
'use strict'; const AWS = require('aws-sdk'); describe('getting things', () => { afterEach(() => AWS.clearAllMocks()); it('returns the thing', async () => { const get = AWS.spyOn('S3', 'getObject').mockReturnValue({ promise: () => Promise.resolve('foo')
3
19
79
+ 7 other calls in file
GitHub: mapbox/aws-sdk-jest
41 42 43 44 45 46 47 48 49 50
AWS.spyOn('S3', 'putObject'); const s3 = new AWS.S3(); expect(jest.isMockFunction(s3.putObject)).toEqual(true); AWS.clearAllMocks(); const after = new AWS.S3(); expect(jest.isMockFunction(after.putObject)).toEqual(false); expect(jest.isMockFunction(after.getObject)).toEqual(false); });
3
19
79
+ 11 other calls in file
16 17 18 19 20 21 22 23 24 25
} afterEach(() => { spyLog.mockClear() spyError.mockClear() AWS.clearAllMocks() }) test('should delete files successfully', async () => { const listFiles = AWS.spyOnEachPage('S3', 'listObjectsV2', [ { Contents: [{ Key: 'test/path/1.txt' }] },
2
10
3
+ 5 other calls in file
aws-sdk.S3 is the most popular function in aws-sdk (7245 examples)