How do you fake sqs in NODEJS

Amazon SQS is a queue service for produce and consume message in any applications.

Some times, During development, You want to test messages for Amazon SQS.

Fake SQS Nodejs Example

First screate a node project

npm init -y

Create a index.js file and below lines of code

  • Import fake-sqs and aws-sdk into the file
const SQSServer = require('fake-sqs')
const AWS = require('aws-sdk')
  • Create a Fake SQS server with ports and optional hosts
const server = new SQSServer(opts)

port: can be zero or any custom port given bootstrap() method

You can start the server using

await server.bootstrap()

Next, Create SQS connection with all region, accessKeyId and Secret key details all details

  const sqs = new AWS.SQS({
    region: 'us-west-2',
    sslEnabled: false,
    accessKeyId: '456',
    secretAccessKey: 'asdfa',
    apiVersion: '2023-01-05'
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.