Interact or test REST resources from the command line.
- API testing (smoke, acceptance)
$ npm install @testingrequired/[email protected]
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.
The format for rest files is not stable and is subject to change with any new release.
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)]
};
- name
string
- method
string
- url
string
- headers
{[string]: string}
- redirects
follow | error | manual
- body
any
Calls url and prints response from rest file
$ restspec run ./tests/rest/google.js
Calls url and runs tests from rest file
$ restspec test ./tests/rest/google.js
MIT - see LICENSE