@gurke/sqs

0.1.6 • Public • Published

@gurke/sqs

A collection of cucumber step definitions to help testing sqs configuration.

Prerequisite

  1. Using Jest as a test runner
  2. Using jest-cucumber library for cucumber setup

Features

Available step definitions:

given(/a (fifo|standard) queue with queue name variable "(.*)" exists/);

given(
  /the following batch of queue messages has been sent to queue with queue name variable "(.*)":/
);

then(/queue with variable name "(.*)" should have "(.*)" (message|messages)/);

then(
  /queue with variable name "(.*)" should have message with the following MessageBody and MessageAttributes/
);

then(
  /queue with variable name "(.*)" should have message with following message Body:/
);

Example usage

import { autoBindSteps, loadFeatures } from 'jest-cucumber';
import {
  sqsSteps,
  sqsCleanUp,
  waitForInFlightMessagesToBeVisible,
} from '@gurke/sqs';

const features = loadFeatures(/* Your feature file(s) */);

const steps = ({ when }) => {
  when(/amazing things happen/, async () => {
    // insert execution of your amazing event(s) / action(s)

    // remember to wait for the message to be visible in the last step of your when scenario
    await waitForInFlightMessagesToBeVisible();
  });
};

afterEach(async () => {
  await sqsCleanUp();
});

autoBindSteps(features, [sqsSteps, steps]);

With this setup, the available step definitions can be use in your feature file.

Default environment variables

The default value of the environment variables for AWS in this library are:

Variable Name Value
AWS_REGION eu-central-1
TEST_SQS_ENDPOINT http://eu-central-1.queue.localhost.localstack.cloud:4566
TEST_AWS_ACCESS_KEY_ID test
TEST_AWS_SECRET_ACCESS_KEY test

If you need to pass a different value, you can configure it by overwriting it.

Readme

Keywords

Package Sidebar

Install

npm i @gurke/sqs

Weekly Downloads

0

Version

0.1.6

License

MIT

Unpacked Size

34.1 kB

Total Files

10

Last publish

Collaborators

  • gurke