Am I able to output and view Frisby.js requests?

1.1k Views Asked by At

I'm getting started with frisby.js and I'm also new to Jasmine and node.js.

After stumbling over some of my first frisby tests, I wanted to know if it were possible to output the requests in my tests to the console so that I could validate I have the correct request headers and request body etc. each time I run my tests with

jasmine-node myproj/spec

I think this might be useful if the requests would also be included into the reports when I run my tests with the --junitreport option

I was originally hoping that running my tests with --verbose would provide this, but --verbose only seems to output the request method and URL of the top level test and not any tests nested under it using after() or afterJSON(), which is also disappointing!

I've tried searching around but did not find an answer to this simple question, any help would be much appreciated thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

In case anyone else runs into this, frisby also has the following inspector:

inspectRequest()

For example, if you have the following a simple test

frisby.create('My Test')
      .get('http://httpbin.org/get?foo=bar&bar=baz')
      .inspectRequest()
      .expectStatus(200)
      .toss();

This will output something similar to the following in your console:

{ json: false,
  uri: 'http://httpbin.org/get?foo=bar&bar=baz',
  body: null,
  method: 'GET',
  headers: 
     { 'content-type': 'application/json' },
  timeout: 5000 }