与你相遇好幸运,mocha接口测试
var rest = require('restler');
var assert = require("assert");
var systemID;
var userID;
console.log('--------------------------------------');
console.log('SYSTEM TEST START ..');
console.log('--------------------------------------');
describe('system',function(){
it('增加',function(done){
rest
.post('http://127.0.0.1:1337/system/',{data:{system:'test',uri:'http://test.com'}})
.on('complete', function(result) {
"use strict";
assert.equal('test',result.result.system);
assert.equal('http://test.com',result.result.uri);
systemID = result.result.id;
done();
});
});
it('修改',function(done){
rest
.put('http://127.0.0.1:1337/system/'+systemID,{data:{system:'test',uri:'http://test2.com'}})
.on('complete', function(result) {
"use strict";
//console.log(result);
assert.equal('test',result.result.system);
assert.equal('http://test2.com',result.result.uri);
done();
});
});
it('查看',function(done){
rest
.get('http://127.0.0.1:1337/system/')
.on('complete', function(result) {
"use strict";
assert.equal('test',result.result[result.result.length - 1].system);
assert.equal('http://test2.com',result.result[result.result.length - 1].uri);
done();
});
});
it('删除',function(done){
rest
.del('http://127.0.0.1:1337/system/'+systemID)
.on('complete', function(result) {
"use strict";
assert.equal('test',result.result.system);
assert.equal('http://test2.com',result.result.uri);
done();
});
});
});
describe('user',function(){
it('增加',function(done){
rest
.post('http://127.0.0.1:1337/user/',{data:{email:'test@test.com',passwd:'test'}})
.on('complete', function(result) {
"use strict";
assert.equal('test@test.com',result.result.email);
userID = result.result.id;
done();
});
});
it('修改',function(done){
rest
.put('http://127.0.0.1:1337/user/'+userID,{data:{email:'test2@test.com'}})
.on('complete', function(result) {
"use strict";
//console.log(result);
assert.equal('test2@test.com',result.result.email);
done();
});
});
it('查看',function(done){
rest
.get('http://127.0.0.1:1337/user/')
.on('complete', function(result) {
"use strict";
assert.equal('test2@test.com',result.result[result.result.length - 1].email);
done();
});
});
it('删除',function(done){
rest
.del('http://127.0.0.1:1337/user/'+userID)
.on('complete', function(result) {
"use strict";
assert.equal('test2@test.com',result.result.email);
done();
});
});
});
与你相遇好幸运,mocha接口测试的更多相关文章
- nodejs+supertest+mocha 接口测试环境搭建
系统接口自动化测试 该框架用于对系统的接口自动化测试(nodejs+supertest+mocha)Homebrew 安装: ruby -e "$(curl -fsSL {+}https:/ ...
- 与你相遇好幸运,服务器node环境安装
>服务器更改root密码 sudo passwd root >服务器ubuntu安装ssh apt-get install openssh-server >服务器开启root用户密码 ...
- 与你相遇好幸运,My Toolkit of Nodejs
>测试:restler.mocha.assert.request.request-promise >安装:nrm >运维:pm2.node-gyp >开发:nodemon.in ...
- 与你相遇好幸运,使用redis设置定时任务
参考链接: Nodejs中使用Redis来完成定时任务 自己在 window 7下编码实现: 1 > 首先查看redis版本: redis-server -v , 版本要求大于等于2.8 2&g ...
- 与你相遇好幸运,制作自己的Yeoman Generator
使用别人写好的生成器: npm install -g yonpm install -g generator-angularyo angular 如何自己制作符合自己心仪的生成器呢: https://g ...
- 与你相遇好幸运,gen8安装
gen8到手后,立马去买了 SSD https://item.jd.com/2010277.html 支架 https://item.jd.com/2671609.html NAS盘 https:// ...
- 与你相遇好幸运,德淘gen8历程
应该是十月底了 , 在浏览色魔张大妈(smzdm) http://www.smzdm.com/p/6517684/ 的时候看见了这个 , 以前大学就想买个这个 , 苦于没钱.... 然后当时打算买 , ...
- 与你相遇好幸运,用sinopia搭建npm私服
需求: >在企业内部搭建私有npm服务器,企业开发人员上传下载自己开发的npm包 >私有npm服务器包不存在时,找npm或者taobao的镜像站点 >服务器硬盘有限,希望只缓存下载过 ...
- 与你相遇好幸运,Postman设置Header不生效问题解决
POstMan安装地址 安装完 , Postman 设置Header的Referer不生效 , 提示 Restricted Header (use postman interceptor) 时 , 要 ...
随机推荐
- bzoj3343
3343: 教主的魔法 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1178 Solved: 527[Submit][Status][Discus ...
- 【USACO 2.4】The Tamworth Two
题意:C代表cows,F代表farmer,一开始都向北,每分钟前进1步,如果前方不能走,则这分钟顺时针转90°,问多少步能相遇,或者是否不可能相遇,10*10的地图. 题解:dfs,记录状态,C和F的 ...
- 解决:/bin/bash: mvn: 未找到命令
在终端执行: sudo apt-get install maven
- js-JavaScript高级程序设计学习笔记20
第二十三章 离线应用与客户端存储 1.离线检测 HTML5定义navigator.onLine属性.还定义了两个事件,online和offline,当网络从离线变为在线或从在线变为离线时在window ...
- Leetcode 40. Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- Theano: CNMeM is disabled, CuDNN not available
Problem Theano: CNMeM is disabled, CuDNN not available Solution cnmem package: https://github.com/NV ...
- Simple Network Management Protocol - SNMP Tutorial
30.9 Simple Network Management Protocol Network management protocols specify communication between t ...
- jQuery插件之Cookie插件使用方法~
一.介绍 1-1.jQuery.Cookie.js插件是一个轻量级的Cookie管理插件.下载地址:jQuery-cookie.js 有需要的朋友,右键另存为即可! 二.使用方法 2-1.引入jQu ...
- js字符串方法
字符串方法根据下标返回字符:str.charAt()//传入一个下标返回字符str.charCodeAt();// 传入一个下标获取编码String.formCharCode();//接受编码,编码转 ...
- Pandas-数据探索
Pandas包对数据的常用探索功能,方便了解数据描述性属性. 目录 基础属性 shape indexs columns values dtype/dtypes 汇总和计算描述统计 count() va ...