https://github.com/2iq/aws-sdk-nock-responses
Collection of nock responses for aws-sdk.
https://github.com/2iq/aws-sdk-nock-responses
aws aws-sdk aws-sdk-javascript nock-responses nodejs testing
Last synced: about 1 month ago
JSON representation
Collection of nock responses for aws-sdk.
- Host: GitHub
- URL: https://github.com/2iq/aws-sdk-nock-responses
- Owner: 2iq
- License: mit
- Created: 2020-11-30T16:56:16.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-10T10:25:31.000Z (about 5 years ago)
- Last Synced: 2025-09-15T19:54:58.265Z (6 months ago)
- Topics: aws, aws-sdk, aws-sdk-javascript, nock-responses, nodejs, testing
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-sdk-nock-responses
Collection of nock responses for aws-sdk.
## Quickstart
Add the `@2iq/aws-sdk-nock-responses` to devDependencies:
```js
{
// ...
"devDependencies": {
// ...
"@2iq/aws-sdk-nock-responses": "0.0.1",
// ...
}
// ...
}
```
Use the lib ([ava] example):
```js
const awsApiMock = require('@2iq/aws-sdk-nock-responses'); // 1️⃣
const underTest = require('..'); // presumed we are in `test` folder
test('should create ecr repo if not existent', t => {
awsApiMock.ecr.repoDoesNotExist(); // 2️⃣
awsApiMock.ecr.repoCreationSuccessful(); // 2️⃣
awsApiMock.ecr.lifecycleUpdateSuccessfull(); // 2️⃣
underTest.run(); // 3️⃣
t.true(awsApiMock.isDone()); // 4️⃣
});
```
1️⃣ `require` the module
2️⃣ Stub AWS API responses
3️⃣ Run the code you want to test (code that calls the AWS API)
4️⃣ Assert that all calls to AWS API were called
[ava]: https://github.com/avajs/ava
## Disclaimer
We created this module to avoid copy and paste of nock objects between test-files and projects.
As of now, it only contains responses that are required in our projects.
The customization of response (like setting own region or accountId) is not implemented if we don't need that in our test.
In that case, the values are hardcoded.
Contributions are welcome!