testingrequired / restspec

Interact or test REST resources from the command line.
MIT License
0 stars 0 forks source link
command-line rest test testing-tools

restspec

Interact or test REST resources from the command line.

Use cases

Installation

$ npm install @testingrequired/restspec@0.0.0

Usage

Rest Files

A rest file defines a single request with optional tests. They are plain javascript files that are intended to be edited as code. They should live with your project's tests.

Warning

The format for rest files is not stable and is subject to change with any new release.

Example

Rest files can be located anywhere.

// ./tests/rest/example.js
module.exports = {
  name: "Example",
  method: "GET",
  url: "http://example.com/",
  headers: {
    "Content-Type": "application/json"
  },
  redirect: "follow",
  tests: (response, assert) => [() => assert.equal(response.status, 200)]
};

Parameters

Run

Calls url and prints response from rest file

$ restspec run ./tests/rest/google.js

Test

Calls url and runs tests from rest file

$ restspec test ./tests/rest/google.js

License

MIT - see LICENSE