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

@byrdware/rester

v0.1.3

Published

REST API Test Runner

Downloads

8

Readme

Rester

REST API Test Runner

NPM Version Build Status Coverage Status License: MIT

Synopsis

An experimental REST API test runner that consumes a postman export file (in JSON or JavaScript format), then runs each and every test item in the file in sequential order, or optionally, a single, named item from the test.

Installation

npm install @byrdware/rester

Motivation

Testing REST API's and microservices is tedious and time-consuming. Perhaps a more thorough search is required, but no good tools have been found to easily and quickly automate a test script for checking and validating an API while under development. This project is an attempt to solve this problem by providing a simple tool, driven by an easily configured JSON/JavaScript file.

Initially the format of this configuration file is simply a postman export file. I am currently reviewing Insomnia export files and planning support in a future release, pull requests are welcome.

Usage

$ rester postman ./test/test-suite.js

  Login User
    √ POST http://localhost:3369/user/login
  Create Records
    √ POST http://localhost:3369/create/
  Retrieve All Records
    √ GET http://localhost:3369/
  Retrieve N Records
    √ GET http://localhost:3369/10/
  Search for Records
    √ GET http://localhost:3369/search
  Update Record
    √ PUT http://localhost:3369/update/L1SEzUhTQ3WNPyKMO1vA
  Delete Record
    √ DELETE http://localhost:3369/delete/uLAkVuFVWvLN1OGp21RQ
  Logout User
    √ GET http://localhost:3369/user/logout

  Tests complete
    8 passing (61 ms)

Command Line Options

The CLI is further configured with the following command line options:

Usage: rester [options] [command]

General Options:
  -V, --version             Output the version number
  -h, --help                Output usage information

Commands:
  postman [options] <file>  Send test items from a postman export file

Postman Options:
  -t, --test <name>         Send only named test

Getting Started

npm install '@byrdware/rester' -D
mkdir rest
$EDITOR rest/simple-rest.js

In your editor:

module.exports = {
  info: {
    name: 'My Test Suite'
  },
  item: [{
    name: 'Login',
    request: {
      method: 'POST',
      header: [{
        key: 'Content-Type',
        value: 'application/json',
      }],
      body: {
        raw: '{ "email": "[email protected]", "password": "0123456789abcdef" }'
      },
      url: {
        protocol: 'http',
        host: [ 'localhost' ],
        port: '80',
        path: [ 'login' ]
      }
    }
  }]
};

Run tests from a shell:

$ ./node_modules/.bin/rester postman rest/simple-rest.js

  Login
    √ POST http://localhost:80/login

  Tests complete
    1 passing (283 ms)

Add a "rest" script to package.json:

"scripts": {
  "test": "mocha",
  ...
  "rest": "rester postman ./rest/simple-rest.js"
}

Then run your tests with:

npm run rest

File Format

This tool currently supports a file format with a minimal subset of the schema described here:

https://schema.getpostman.com/json/collection/v2.1.0/collection.json

Unit Testing the Rester Distribution

Clone the github repository:

git clone https://github.com/byrdware/rester.git

and then:

npm test

or, alternately:

node test/www
npm start

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.