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')
fork icon3
star icon19
watch icon79

+ 7 other calls in file

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);
});
fork icon3
star icon19
watch icon79

+ 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' }] },
fork icon2
star icon10
watch icon3

+ 5 other calls in file