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

testiny

v0.0.5

Published

A stupid simple declarative API testing tool

Downloads

16

Readme

Testiny

A declarative way to test RESTful API's with a single JS config.

Testiny is a API testing tool for any language. It checks a single JS config file and parses to generate tests. Every generate will run and produce either a success or an error.

usage

Usage

Options:
  -V, --version       output the version number
  -h, --help          display help for command

Commands:
  generate [options]  Initializes a Testiny JS config file
  run [options]       Run config file
  help [command]      display help for command

JS Testing Schema

  • host <string> required - this is the host name of the api
  • isHttps <boolean> optional - indicate whether the api domain is https, (default: false)
  • authentication <object> optional
    • strategy <string> required - oneOf ["FIREBASE"]
    • placement <object> required where to place the JWT token or cookie
      • type <string> required oneOf ["header", "payload", "query", "cookie"]
      • key <string> required the name of the token or cookie to inject the value in
    • apiKey <string> required api key for the firebase app
    • email <string> required email of the user to authenticate
    • password <string> required password of the user to authenticate
  • beforeAll Array<object> | <function(baseUrl, authValue, authentication)> optional can either be an array of objects of tests (see below) or can be a function which gets passed three parameters. If an error happens, throw the error inside the function
  • tests Array<object> optional the tests in which will
    • name <string> required name of the test, can be anything but should be descriptive
    • authenticated <boolean> optional whether or not this request should be authenticated (default: false)
    • path <string> required path of the api route
    • method <string> required method of the api route to test
    • skip <boolean> optional skips this test (default: false)
    • validateResponse <AxiosResponse=>{}>_ optional function to call for each test, it accepts an axios response object and expects an object thrown in format of {message: 'your message', response: response} (default: ()=>{})
    • payloads <object> optional method of the api route to test
    • whitelistHttpCodes Array<number> optional a list of status codes that are considered successful. ie if passed [500] then this test will be treated as a successful test

Example file

// schema.js
module.exports = {
  host: "api.todo.com",
  isHttps: true,
  authentication: {
    strategy: "FIREBASE",
    placement: {
      type: "header",
      key: "Token",
    },
    apiKey: "KSzafeFYRfeeIs3368E1RD4jpdWfeafdRjhtfee",
    email: "[email protected]",
    password: "myPassword123",
  },
  tests: [
    {
      name: "get all todos",
      authenticated: false,
      path: "todos/all",
      method: "GET"
    },
    {
      name: "add todos",
      authenticated: true,
      path: "todos/add",
      method: "POST",
      payload: {
        todo: ["get milk", "drive car", "shower"]
      }
    },
  ],
};

The above json file will be parsed and converted to 4 tests dynamically, it will have the following generated and runned:

GET https://api.todo.com/todos/all
token: <id token value here>
POST https://api.todo.com/todos/add HTTP/1.1
Content-Type: application/json
Token: <id token value here>

{
    "todo": "get milk"
}
POST https://api.todo.com/todos/add HTTP/1.1
Content-Type: application/json
Token: <id token value here>

{
    "todo": "drive car"
}
POST https://api.todo.com/todos/add HTTP/1.1
Content-Type: application/json
Token: <id token value here>

{
    "todo": "shower"
}

Supported authentication

Authentication is a very important thing when testing APIS. There is currently out of box support for Firebase auth.

Firebase

{
  strategy: "FIREBASE",
  placement: {
    type: "header",
    key: "Token",
  },
  apiKey: "KSzafeFYRfeeIs3368E1RD4jpdWfeafdRjhtfee",
  email: "[email protected]",
  password: "myPassword123",
}

Since there is only one supported method of authentication, any PR's would be greatly appreciated 🙏🙏🙏