Skip to content

Instantly share code, notes, and snippets.

@mogocat
Last active March 7, 2017 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mogocat/e15a19cb857217a6f7d3ef19caa13bc0 to your computer and use it in GitHub Desktop.
Save mogocat/e15a19cb857217a6f7d3ef19caa13bc0 to your computer and use it in GitHub Desktop.
[API测试脚本] #tags: should, supertest, restapi, mocha
var app = require("../app")
var supertest = require("supertest")
var should = require('should')
var request = supertest(app)
// 定义路由
describe('测试配件模块', function(){
it('/accessory/table 返回配件信息数组', function(done){
request.get('/accessory/table')
.query({cate: 1})
.end(function(err, res){
should.not.exist(err)
let body = res.body
body.should.be.instanceof(Array)
if(body.length > 0){
body[0].should.have.keys('id', 'name', 'cate', 'code', 'note', 'serial')
}
done()
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment