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

api-piki

v1.2.1

Published

A Web API test skeletons generator for APIs described using OpenAPI Specification (fka Swagger).

Downloads

14

Readme

Web APIs testing for lazy cats.

API-Piki for Node.js helps you generate and write recurrent test skeletons to catch bugs in your APIs described by an OpenAPI Specification (fka Swagger) document.

travis build Coverage Status Known Vulnerabilities npm version Commitizen friendly

API-Piki

If your Web/REST APIs are described by the OpenAPI Specification (fka Swagger), this tool generates some recurrent common test cases skeletons to extensively test your API.

API-Piki tools generate test cases written in JavaScript / Node.js, using Mocha and Chai / Should as foundation testing frameworks.

API-Piki is the perfect companion if you use arrest framework to design and build your Web APIs with Node.js.

Installation

Required: Node.js >= v7.7.4

npm install -g api-piki

Quick Start

The quickest way to get started is to use the piki executable command-line tool to generate your tests, as shown below:

$ piki -o api-tests <OpenApi Spec File or URL>

where <OpenApi Spec File or URL> is the OpenAPI Spec local file path or its remote URL.

API-Piki generates all the common test suites in the specified output directory. Then, your tests are runnable (please, read the Generated code & Philosophy section for more detailed info):

$ cd api-tests && npm i && npm test

Command Line Options

The piki tests generator tool can also be further configured with the following command line flags.

-h, --help          output usage information
-V  --version       output the version number
-o, --out           set output directory path   
-f, --forceAuth     force tests generation using Basic Authentication 

Generated Code & Philosophy

Testing Web/REST APIs can be tedious and repetitive. API-Piki philosophy is to provide a simple tool to generate some "Black Box", recurrent and common test cases skeletons to test Web APIs described by OpenAPI Specification; then, the generated test skeletons can be edited and adapted in order to strictly match the particular API implementation/testing strategy.

API-Piki tool generates the code for a set of common Mocha/Chai test suites. A different JavaScript file is generated per method-endpoint-path. Generated code is not intended to be runnable as it is (despite it can be run). Instead, the ideal workflow is the following:

  1. Run piki tool against an OpenAPI spec document (file or URL);
  2. Open and edit the generated test files in order to complete or adapt them (feel free to add new tests!). In particular, search for the code lines using Mocha's describe.skip() function (read more here) and choose which to remove and adapt to enable the single test cases. Also, please note that the current API-Piki version doesn't generate HTTP request bodies for POSTs/PUTs (it's on our roadmap).
  3. Run the tests.

WARNING: Current version of the piki tool overwrites existing tests if you run it specifying an existing directory. So, be careful running the tool again if you edited the code.

Limitations

This version has the following limitations:

  • application/json is the only supported format for endpoints;
  • only Basic Authentication is supported as security scheme;
  • it doesn't generate tests for pagination path params;
  • it doesn't generate tests for query params;
  • it doesn't generate JSON Object bodies for HTTP requests (nor parses JSON Schemas);

Contributors

Antonio Pintus