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

enqueuer-cucumber

v2.0.3

Published

Plugin to implement cucumber steps as enqueuer requisitions

Downloads

18

Readme

Enqueuer Cucumber Integration

Instalation:

Install cucumber-js and enqueuer.

Install EnqueuerCucumber integration plugin:

npm i -D enqueuer-cucumber

Usage:

Then create a Cucumber Step Definition that load its steps from Enqueuer, like:

const { Configuration } = require('enqueuer');
const { EnqueuerStepDefinitions } = require('enqueuer-cucumber');
const path = require('path');
const enqueuerFiles = path.join(__dirname, './enqueuer/*.yaml');

Configuration.getInstance()
    .addFiles(enqueuerFiles);
    .addPlugin('enqueuer-plugin-amqp')

new EnqueuerStepDefinitions().build();

In the above example, we are saying to EnqueuerCucumber plugin to load its steps according to the expression ./enqueuer/*.yaml.

Then, lets create some test scenarios with cucumber:

Feature: Tickets issuing for my Tickets Service

  Scenario: Issue a ticket for a given order
    Given I have an order to buy a ticket for a desired event
    When I receive a payment notification for that order
    Then I should call the issuing API
    And I uptade the order with the tickets

Then, we can write our step definitions with enqueuer:

requisitions:
- name: I have an order to buy a ticket for a desired event
  onInit:
      store:
          orderId: order123
- publishers:
  -   name: I receive a payment notification for that order
      type: amqp
      payload: 
          orderId: `<<orderId>>`
      routingKey: orderchange.payments

  subscriptions:
  -   type: http
      name: I should call the issuing API
      endpoint: /my-issuing-endpoint
      port: 9085
      method: POST
      response:
          status: 200
          payload: 
              tickets:
                  - `<<ticketNumner>>`
      onMessageReceived:
          assertions:
          -   expect: params.orderId
              toBeEqualTo: `<<orderId>>`
  -   type: http
      name: I uptade the order with the tickets
      endpoint: /orders/:orderId/tickets
      port: 9085
      method: POST
      response:
          status: 204
      onMessageReceived:
          assertions:
          -   expect: JSON.parse(body).tickets[0]
              toBeEqualTo: `<<ticketNumner>>`

We just need to ensure that the we use the same names for the steps and enqueuer definitions.

If we want to create parameterized steps, we can follow the same rules applicable to cucumber JS.

For example, if we want to modify the previous example to customize some values used in the tests, we could rewrite it as:

Feature: Tickets issuing for my Tickets Service

  Scenario Template: Issue a ticket for a given order
    Given I have the order "<orderId>" to buy a ticket for a desired event
    When I receive a payment notification for the order "<orderId>"
    Then I should generate the ticket "<ticketNumber>" for the order "<orderId>"
    And I uptade the order "<orderId>" with the ticket "<ticketNumber>" 

    Examples:
        | orderId | ticketNumber |
        |    order1 |   TKT001 | 
        |    order2 |   TKT002 | 
        |    order3 |   TKT003 | 

Then, we can write our step definitions with enqueuer:

requisitions:
- name: I have the order {string} to buy a ticket for a desired event
  variables:
    - orderId
- publishers:
  -   name: I receive a payment notification for the order {string}
      variables:
        - orderId
      type: amqp
      payload: 
          orderId: `<<orderId>>`
      routingKey: orderchange.payments

  subscriptions:
  -   type: http
      name: I should generate the ticket {string} for the order {string}
      variables:
        - ticketNumber
        - orderId
      endpoint: /my-issuing-endpoint
      port: 9085
      method: POST
      response:
          status: 200
          payload: 
              tickets:
                  - `<<ticketNumner>>`
      onMessageReceived:
          assertions:
          -   expect: params.orderId
              toBeEqualTo: `<<orderId>>`
  -   type: http
      name: And I uptade the order {string} with the ticket {string}
      variables:
        - orderId
        - ticketNumber
      endpoint: /orders/:orderId/tickets
      port: 9085
      method: POST
      response:
          status: 204
      onMessageReceived:
          assertions:
          -   expect: JSON.parse(body).tickets[0]
              toBeEqualTo: `<<ticketNumner>>`