与你相遇好幸运,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) 时 , 要 ...
随机推荐
- 理解C# 4 dynamic(1) - var, object, dynamic的区别以及dynamic的使用
阅读目录: 一. 为什么是它们三个 二. 能够任意赋值的原因 三. dynamic的用法 四. 使用dynamic的注意事项 一. 为什么是它们三个? 拿这三者比较的原因是它们在使用的时候非常相似.你 ...
- 开始学emacs-1
读readme http://ftp.gnu.org/gnu/emacs/windows/README
- ORACLE 中的 ROW_NUMBER() OVER() 分析函数的用法
ORACLE 中的 ROW_NUMBER() OVER() 分析函数的用法 ROW_NUMBER() OVER(partition by col1 order by col2) 表示根据col1分组, ...
- #MySQL 5.7.8 支持Json类型
As of MySQL 5.7.8, MySQL supports a native JSON data type that enables efficient access to data in J ...
- 关于WEB项目的一点想法
有点失落.迷茫,差点在上班的时候发了火.原因是之前离职的一位同事,在代码里不加注释,而且百般偷懒,致使很多应该的验证没有验证,很多应该考虑到的情况没有考虑.因为是老员工,我相比他来说是新员工.气势上总 ...
- Java编程思想重点笔记(Java开发必看)
Java编程思想重点笔记(Java开发必看) Java编程思想,Java学习必读经典,不管是初学者还是大牛都值得一读,这里总结书中的重点知识,这些知识不仅经常出现在各大知名公司的笔试面试过程中,而 ...
- Google 地图 API V3 之事件
Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...
- 添加删除表格append或 createElement
方法一: js代码:增加一行五列的表格 function AddList(){ $len= document.getElementsByName('goods_name[]').length; obj ...
- marquee标签,好神奇啊...
<html><body><div style="height:190; margin-top:10; margin-bottom:10; width:96%; ...
- Coursera-Getting and Cleaning Data-Week2-课程笔记
Coursera-Getting and Cleaning Data-Week2 Saturday, January 17, 2015 课程概述 week2主要是介绍从各个来源读取数据.包括MySql ...