npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-mocks

v0.0.15

Published

Mocks of key AWS services for testing and local development

Downloads

21

Readme

aws-mocks

Build Status Coverage Status

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

npm 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:

const env = process.env.NODE_ENV;
let AWS;

// if the environment is a local one, require mocks
if (!env || env === "development") {
  AWS = require("aws-mocks");
// otherwise, require the real SDK
} else {
  AWS = require("aws-sdk");
}

You can also (and probably should) mock services at the service level rather than the SDK level:

const AWS = require("aws-sdk");
const MockAWS = require("aws-mocks");

const env = process.env.NODE_ENV;
let sqs;

if (!env || env === "development") {
  sqs = new AWS.SQS();
} else {
  sqs = new MockAWS.SQS();
}

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 variable MOCK_SQS_DB
      • Default collection name mockSQS (not configurable yet)

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.