Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vlucas/frisby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: glebmlk/frisby-middleware
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 4 commits
  • 3 files changed
  • 2 contributors

Commits on Mar 4, 2019

  1. Update README.md

    glebmlk authored Mar 4, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2ef004f View commit details
  2. added: middleware support

    Gleb Myalik committed Mar 4, 2019
    Copy the full SHA
    20329d1 View commit details
  3. Merge pull request #1 from glebmlk/feature/middleware-support

    Middlewaer support
    glebmlk authored Mar 4, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    19fb9e4 View commit details
  4. updated: info

    Gleb Myalik committed Mar 4, 2019
    Copy the full SHA
    f53a7aa View commit details
Showing with 28 additions and 10 deletions.
  1. +4 −6 README.md
  2. +3 −3 package.json
  3. +21 −1 src/frisby/spec.js
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@
[![Build
Status](https://travis-ci.org/vlucas/frisby.png?branch=master)](https://travis-ci.org/vlucas/frisby)

![Frisby.js](https://www.frisbyjs.com/assets/frisbyjs.png)

## Introduction

Frisby.js an API testing tool built on top of
@@ -16,7 +14,7 @@ fast and fun.

Install Frisby v2.x from NPM into your project:

npm install frisby --save-dev
npm install frisby-middleware --save-dev

## Creating Tests

@@ -25,7 +23,7 @@ Install Frisby v2.x from NPM into your project:
The minimum setup to run a single test expectation.

```javascript
const frisby = require('frisby');
const frisby = require('frisby-middleware');

it('should be a teapot', function () {
// Return the Frisby.js Spec in the 'it()' (just like a promise)
@@ -39,7 +37,7 @@ it('should be a teapot', function () {
A more complex example with nested dependent Frisby tests with Frisby's Promise-style `then` method.

```javascript
const frisby = require('frisby');
const frisby = require('frisby-middleware');
const Joi = frisby.Joi; // Frisby exposes Joi for convenience

describe('Posts', function () {
@@ -129,7 +127,7 @@ can be used inside the `then` method to perform additional or custom tests on
the response data.

```javascript
const frisby = require('frisby');
const frisby = require('frisby-middleware');

it('should be user 1', function () {
return frisby.get('https://api.example.com/users/1')
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "frisby",
"version": "2.1.1",
"name": "frisby-middleware",
"version": "1.0.0",
"description": "Frisby.js v2.0: REST API Endpoint Testing built on Jasmine",
"homepage": "http://frisbyjs.com",
"author": "Vance Lucas <vance@vancelucas.com>",
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "http://github.com/vlucas/frisby"
"url": "http://github.com/glebmlk/frisby-middleware"
},
"keywords": [
"testing",
22 changes: 21 additions & 1 deletion src/frisby/spec.js
Original file line number Diff line number Diff line change
@@ -19,13 +19,15 @@ class FrisbySpec {

this._timeout;
this._setupDefaults = {};

this._middleware = [];
}

/**
* Call function to do some setup for this spec/test
*/
use(fn) {
fn(this);
this._middleware.push(fn);
return this;
}

@@ -88,6 +90,15 @@ class FrisbySpec {
}
});
})
.then(() => {
this._middleware.forEach(fn => {
try {
fn(this);
} catch (error) {
console.log('Middleware error: ' + error);
}
});
})
.then(() => {
return this._response;
});
@@ -153,6 +164,15 @@ class FrisbySpec {
}
});
})
.then(() => {
this._middleware.forEach(fn => {
try {
fn(this);
} catch (error) {
console.log('Middleware error: ' + error);
}
});
})
.then(() => {
return this._response;
});