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

governify-tester

v0.0.2

Published

Testing endpoints via http requests

Downloads

19

Readme

alt build:passed

1. Install the package

npm install governify-tester --save

2. Install the governify-cli and use it in your shell

npm install governify-cli -g

see doc

3. Use from code

Import library in you code

var tester = require("governify-tester");
  • All results generate a logfile into the directory where is launched.
  • Also you can obtain the results of each test. It is because all methods return a Promises

3.1 Simple requests with duration

  • Params: URL, method , number of times, duration [body], [headers]
tester.doParallelRequestWithDuration("https://www.google.es/", "GET", 2, 1);

If you need the result, you can use the method then because it's a promise

tester.doParallelRequestWithDuration("https://www.google.es/", "GET", 2, 1).then(function(success) {
    console.log(success);
});
  • You can pass body for test. Only you need to pass body like a string.
  • You could also pass headers in next params

lib.doParallelRequestWithDuration("https://jsonplaceholder.typicode.com/posts", "POST", 2, 1, "{	\"isagroup\": 1}");

3.2 Simple requests once

You only test endpoint n times once.

  • Params: URL, method , number of times, [body], [headers]

tester.doOneStackOfRequest("http://google.es", "GET",2);

It is also possible to pass body and headers in the same order that the first one.

3.3 Simple requests infinite

This one is special because not return any result a need that you stop it.

  • Params: URL, method , number of times, [body], [headers]

tester.doRequests("http://google.es", "GET", 2);

3.4 Read test from file

This options is strict. It only has certain types that will be described below. You must write in yaml format and you only have to indicate the path of file.

  • Params: Path
tester.doParallelRequestFromfile('./test.yaml');

Types of tests for config file

  • long

testId: idoftest
type: long
url : https://twitter.com/
duration: 3 #seconds
count: 2 #number of times
method: GET
  • interval

You have to define intervals a its duration necessarily.

testId: validation14
type: interval
url: http://localhost:3000/test
request:
  method: POST
  headers:
    content-type: application/json
    heade1: val
  body:
    id: MyID
    value: XXX
tenants:
  - id: t1
    intervals:
      - 8
      - 5
    duration: 1
  - id: t2
    intervals:
      - 6
      - 4
    duration: 1
  - id: t3
    intervals:
      - 1
      - 8
    duration: 1
  - id: t4
    intervals:
      - 3
      - 3
    duration: 1
  • random

You need to write an array within the body

testId: validation12
type: random
url : https://jsonplaceholder.typicode.com/posts
duration: 4 #seconds
count: 10
request:
  method: POST
  headers:
    content-type: application/json
  body: #randomize in body
    id:
      - prueba
      - prueba1
      - prueba2
      - prueba3
      - prueba4
    value:
      - value
      - value1
      - value2
      - value3
      - value4
    date:
      - Date #currently date
  • randomTemplate

testId: validation11
type: randomTemplate
url : https://jsonplaceholder.typicode.com/posts
duration: 4 #seconds
count: 10
request:
  method: POST
  randomFields:
    id:
      - prueba
      - prueba1
      - prueba2
      - prueba3
      - prueba4
    value:
      - value
      - value1
      - value2
      - value3
      - value4
    date:
      - Date #currently date
  headers:
    content-type: application/json
    #randomize in body
  body: >
          {
          "id": "{{id}}",
          "value": "{{value}}",
          "date": "{{date}}"
          }

Latest release

The version 0.0.2 is the latest stable version of governify-tester component. see release note for details.

For running:

  • Download latest version from 0.0.2