Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.
/ restspec Public archive

Interact or test REST resources from the command line.

License

Notifications You must be signed in to change notification settings

testingrequired/restspec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

restspec

Interact or test REST resources from the command line.

Use cases

  • API testing (smoke, acceptance)

Installation

$ npm install @testingrequired/[email protected]

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

  • name string
  • method string
  • url string
  • headers {[string]: string}
  • redirects follow | error | manual
  • body any

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

About

Interact or test REST resources from the command line.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published