Installations
npm install aws-mocks
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=4
Score
68.9
Supply Chain
89.1
Quality
73.5
Maintenance
25
Vulnerability
99.3
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
cwhenderson20
Download Statistics
Total Downloads
18,069
Last Day
3
Last Week
11
Last Month
55
Last Year
549
GitHub Statistics
2 Stars
65 Commits
5 Forks
4 Watching
1 Branches
3 Contributors
Bundle Size
691.12 kB
Minified
174.27 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.0.15
Package Id
aws-mocks@0.0.15
Unpacked Size
55.97 kB
Size
12.86 kB
File Count
46
Total Downloads
Cumulative downloads
Total Downloads
18,069
Last day
0%
3
Compared to previous day
Last week
-56%
11
Compared to previous week
Last month
161.9%
55
Compared to previous month
Last year
-13.1%
549
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
aws-mocks
This module is intended to be a drop-in replacement for the node.js aws-sdk for use in local environments when it's not ideal to hit true AWS endpoints. This is not a mocking service for unit testing as it brings in outside dependencies such as mongodb and the file system (for a unit testing, look to this module); it could, however, be used for integration and functional testing.
Please note: As explained below, this module currently only mocks SQS, and not even completely. If you are looking to mock a different AWS service, I'd love your help getting started!
Installation
1npm install -D aws-mocks
Usage
It's up to you how you determine when the mock services should be used over the real ones, though you'll likely make a determination based on NODE_ENV
. For example:
1const env = process.env.NODE_ENV; 2let AWS; 3 4// if the environment is a local one, require mocks 5if (!env || env === "development") { 6 AWS = require("aws-mocks"); 7// otherwise, require the real SDK 8} else { 9 AWS = require("aws-sdk"); 10}
You can also (and probably should) mock services at the service level rather than the SDK level:
1const AWS = require("aws-sdk"); 2const MockAWS = require("aws-mocks"); 3 4const env = process.env.NODE_ENV; 5let sqs; 6 7if (!env || env === "development") { 8 sqs = new AWS.SQS(); 9} else { 10 sqs = new MockAWS.SQS(); 11}
Requirements
In order to emulate AWS service functionality, it is necessary to rely on external resources. Listed below are the dependencies for each service. If you do not plan on using various services, don't worry about installing the services' dependencies.
- SQS
- mongodb
- Default connection string:
mongodb://localhost:27017
, configurable with environment variableMOCK_SQS_DB
- Default collection name
mockSQS
(not configurable yet)
- Default connection string:
- mongodb
Limitations
It should go without saying that mocking AWS services is a very difficult job to get right. AWS services have many intricacies and idiosyncracies that would be difficult to tease out without very extensive testing.
Additionally, it would be impossible to make the mocks work exactly like their AWS counterparts even with a perfect knowledge of their functioning due to the distributed nature of the AWS infrastructure. Therefore, these mocks are meant to be basic replacements, not perfect drop-ins.
Currently, the only service implemented is SQS (that's what I needed first), and not all methods are fleshed out (though the basic ones are).
Services and Methods Implemented
- SQS (docs)
changeMessageVisibility
deleteMessage
getQueueUrl
listQueues
receiveMessage
sendMessage
setQueueAttributes
Notes
If you have any interest in helping develop service mocks, please submit a PR! There's no way I can do all of this myself. 😉
Also, since this is so new (0.0.8 release!), expect the API to contain breaking changes on minor versions.
Contributing
I'd love your help developing new feaures, so don't be shy to submit PRs! I don't have a huge amount of time to develop mocks for each service, so I'll do the ones I need first, which will likely be SQS, S3, Glacier, SNS, and maybe Lambda.
This module uses the awesome (but still new) AVA for testing and ESLint for linting.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 3/29 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Score
2.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More