vlucas
Frisby

Updated a month ago

Frisby.js

The Easiest And Fastest REST API Testing Framework Out There

Frisby makes REST API testing easy, fast, and fun. Frisby.js comes loaded with many built-in tools for the most common things you need to test for to ensure your REST API is working as it should, and returning the correct properties, values, and types.

When you need something custom, Frisby.js also provides an easy way to customize and extend assertions to make your job easier, with less repetitive and tedious code.

A Simple Example

The most basic check of ensuring a URL returns a specific status code:

const frisby = require('frisby');

it ('should return a status of 200', function (done) {
  frisby
    .get('http://api.example.com')
    .expect('status', 200)
    .done(done);
});

Checking a JSON Response Body

A more useful and thorough test might make several assertions on the actual JSON response. Frisby.js makes this easy:

const frisby = require('frisby');
const Joi = frisby.Joi; // Frisby exports Joi for convenience on type assersions


it ('should return a status of 200', function (done) {
  frisby
    .get('https://jsonfeed.org/feed.json')
    .expect('json', 200)
    .expect('json', 'version', 'https://jsonfeed.org/version/1')
    .expect('json', 'title', 'JSON Feed')
    .expect('jsonTypes', 'items.*', { // Assert *each* object in 'items' array
      'id': Joi.string().required(),
      'url': Joi.string().uri().required(),
      'title': Joi.string().required(),
      'date_published': Joi.date().iso().required(),
    })
    .done(done);
});

Gain Confidence In Your API

Check out the Getting Started page to setup Frisby.js in your project.

Happy testing!