Inspectors

If you need to get more information about the HTTP request, response, body, JSON, etc. Frisby has several built-in helpers that log information to the console for you to see.

frisby.inspectJSON()

Prints formatted and spaced JSON to the console.

const frisby = require('frisby');

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

Output:

{
  "ping": "pong"
}

frisby.inspectResponse()

Inspect HTTP response object (full fetch() request object dumped).

frisby.inspectRequest()

Inspect HTTP request object (full fetch() request object dumped).

frisby.inspectRequestHeaders()

Inspect HTTP request headers.

frisby.inspectBody()

Inspect raw, unparsed HTTP response body text. Useful for debugging why an API is not returning valid JSON, etc.

frisby.inspectStatus()

Inspect HTTP response status code.

frisby.inspectHeaders()

Inspect HTTP response headers.

Last updated