Skip to content
Vance Lucas edited this page Jul 27, 2017 · 3 revisions

Upgrading From Frisby 0.x to 2.x

A lot has changed since the last Frisby release!

Announcement Issue: https://github.com/vlucas/frisby/issues/316

Primary Changes

  • Frisby v2 no longer calls any Jasmine functions like describe or it, etc. You must now define your own jasmine test, and then use Frisby inside it for issuing HTTP requests and running assertions on the response.
  • Smaller API: expect(<type>, <...args>) and expectNot(<type>, <...args>) are the only expectation methods now. The expectNot method simply inverts the expectation (i.e. it expects an error to be thrown)

Code Example:

v0.8.5

Frisby used to create the whole Jasmine test for you:

var frisby = require('frisby');

frisby.create('should get user Joe Schmoe')
  .get(testHost + '/users/1')
  .expectStatus(200)
  .expectJSONContains({
    id: 1,
    email: 'joe.schmoe@example.com'
  })
  .toss();

v2

The old way caused lots of issues and limited flexibility, so now Frisby v2 does not:

var frisby = require('frisby');

it('should get user Joe Schmoe', function(doneFn) {
  frisby.get(testHost + '/users/1')
    .expect('status', 200)
    .expect('json', {
      id: 1,
      email: 'joe.schmoe@example.com'
    })
    .done(doneFn);
});
Clone this wiki locally