| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

REST API 测试框架:Frisby.js

Frisby.js 是一个 Node.js 和 Jasmine 上的 REST API 测试框架,让测试 API EndPoints更简单,更快捷,更有趣。

var frisby = require('../lib/frisby');    var URL = 'http://localhost:3000/';  var URL_AUTH = 'http://username:password@localhost:3000/';    frisby.globalSetup({ // globalSetup is for ALL requests    request: {      headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' }    }  });    frisby.create('GET user johndoe')    .get(URL + '/users/3.json')    .expectStatus(200)    .expectJSONTypes({      id: Number,      username: String,      is_admin: Boolean    })    .expectJSON({      id: 3,      username: 'johndoe',      is_admin: false    })    // 'afterJSON' automatically parses response body as JSON and passes it as an argument    .afterJSON(function(user) {      // You can use any normal jasmine-style assertions here      expect(1+1).toEqual(2);        // Use data from previous result in next test      frisby.create('Update user')        .put(URL_AUTH + '/users/' + user.id + '.json', {tags: ['jasmine', 'bdd']})        .expectStatus(200)      .toss();    })  .toss();

项目主页:http://www.open-open.com/lib/view/home/1389164280750

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1389164280750.html
Frisby.js 测试工具