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

@maibornwolff/alt-core-js

v1.18.9

Published

Simple test framework supporting execution of different `scenarios` based on `action` templates. The framework supports definition of different action types in an *yaml* format, including e.g. which endpoints have to be called with which parameters as wel

Downloads

335

Readme

GitHub Npm Version Docker Runner Github Build & Test

The ALT framework is designed to test logic that spans multiple services/endpoints which might use different technologies and protocols.

It does so by executing scenarios (1 scenario = 1 complete use case) which are composed of actions (e.g. 1 action could be a call to and response from a service).

The framework supports the definition of different action types in a yaml format, including e.g. which endpoints have to be called with which parameters as well as defining validation rules to be applied on the responses. It also supports detailed report creation of the test results. For more detailed documentation, check out the wiki!

Features

  • simple definition of reusable REST, MQTT, WS, etc. action templates
  • ...
  • using Variables across multiple actions
  • validation of response payload from a REST action
  • ...
  • automatic retries of REST requests
  • automatic reconnections of WS sessions
  • ...
  • filtering on incomming MQTT & WS messages
  • publishing & listening of protobuf messages on MQTT broker

Get Started

First of all, you have to define actions (see Actions) which should be invoked. Let's say we want to test creation of new users in our system. For that, we'd need two actions: one for creating new user and one for retrieving the created user and checking if the attributes were stored correctly:

src/actions/create-new-user.yaml

type: REST
service: https://reqres.in/api
endpoint: /users
method: POST
headers:
  Content-Type: application/json
data:
  name: James
  job: Agent
responseValidation:
  - "res.data.first_name === James"

src/actions/query-user.yaml

type: REST
service: https://reqres.in/api
endpoint: /users/2
method: GET
responseValidation:
  - "res.data.first_name === Janet"

In order to execute those actions we need a 'playbook' that defines which action should be executed in which order: this is exactly what a scenario (see Scenarios) is made for:

src/scenarios/s1-my-first-scenario.yaml

description: "testing User-API of the system"
actions:
  - name: create-new-user
  - name: query-user

Scenarios also allow to reuse existing actions:

src/scenarios/s2-my-custom-scenario.yaml

description: "testing if the 'job' property is being saved correctly"
actions:
  - name: create-new-user
    data:
      name: Steve
      job: Teacher
    responseValidation:
      - "res.data.job === Teacher"

Now to run our scenarios, we have basically two options: either using plain JS or via custom build Docker image:

Node

First of all we need to download the ALT's dependency:

npm i -s @maibornwolff/alt-core-js

And then simply call the runScenario main entrypoint providing the paths to our scenarios' and actions directory:

const ALT = require('@maibornwolff/alt-core-js');
ALT.runScenario('src/scenarios/s1-my-first-scenario.yaml', 'src/actions');

Docker

There is special runner image available (see Docker Hub) which already contains the core framwork and also an invokation script for running a particular scanario. You can either use it in raw or as runner image on CI platforms like e.g. GitLab.

Example: Docker CLI

docker run
  -v `pwd`/src:/src                           # mounting scenarios' & actions' root directory
  -e ALT_SRC=/src                             # declaring the mounted path as resource directory
  -v `pwd`/output:/alt-runner-app/out         # output directory where .log files and diagrams will be saved after the execution
  maibornwolff/alt-runner-image:latest
  runScenario s1-my-first-scenario.yaml       # run command with scenario-name as input param

Example: .gitlab-ci.yml

run-my-scenario:
  stage: test
  image: maibornwolff/alt-runner-image:latest
  script:
  - export ALT_SRC=$(pwd)/src                 # directory path containing ./scenarios & ./actions directories
  - runScenario s1-my-first-scenario.yaml     # execution script available inside the container: 'runScenario'
  when: manual
  ...

Environment Config

todo

Reporting

Logging

During the executing there are 2 kind of logging: basic information on which Scenario/Action is being executed is logged to the console while detailed log containing Actions' paramters, results and stack traces are logged to files which are stored under out/: each scenario logs into its own .log file!

Diagrams

The framework can automatically create sequence diagrams from the given scenario definition which are also saved in out/;

Build locally

$ npm install
$ tsc
$ npm test

...