0.0.19 • Published 6 years ago
@specialblend/aws-sdk-mock v0.0.19
@specialblend/aws-sdk-mock
CLI utility to easily build mocks for aws-sdk
installation
# install as project-level (recommended)
npm install -D @specialblend/aws-sdk-mock
# install as system-level
npm install -g @specialblend/aws-sdk-mock
testing/mocking
// foo.test.js
import { S3 } from 'aws-sdk'
import foo from './foo'
jest.mock('aws-sdk')
describe('foo', () => {
const Key = 'example-key'
const mockedBody = 'example body'
const mockedResult = {
Body: Buffer.from(mockedBody),
}
const expectedPayload = {
Bucket: 'example-bucket',
Key,
}
beforeAll(() => {
S3.getObject.mockResolvedValueOnce(mockedResult)
})
test('calls S3.getObject with expected params', async() => {
const result = await foo(Key)
expect(S3.getObject).toHaveBeenCalledWith(expectedPayload)
expect(result).toBe(mockedBody)
})
})
CLI examples
# generates mocks for S3, DynamoDB to file __mocks__/aws-sdk.js
aws-sdk-mock -s S3 -s DynamoDB
# generates mocks for SNS to file aws-sdk.mock.js
aws-sdk-mock -s S3 -s DynamoDB -o aws-sdk.mock.js
see example output in mocks/aws-sdk.js
CLI syntax
Usage: aws-sdk-mock [options]
build mocks for selected AWS SDK services
Options:
-o, --output <outputFile> Specify the output file (default: "__mocks__/aws-sdk.js")
-s, --service <name> Add a AWS SDK service (case-sensitive) (default: [])
-h, --help output usage information
0.0.19
6 years ago
0.0.18
6 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago
0.0.0
6 years ago