我想为 Restful Endpoint 编写单元测试,但每当我运行 npm test 时。我收到错误 Uncaught TypeError: Cannot read property 'apply' of undefined 。
let chai = require('chai')
let chaiHttp = require('chai-http')
let home = require('../routes/home')
let user = require('../routes/users')
//Assertion Style
chai.should()
chai.use(chaiHttp)
describe('chow Api', () => {
// users
describe("GET /api/chow/home", () => {
it('it should render Welcome to Homepage', (done) =>{
chai.request(home)
.get("/api/chow/home")
.end((err, response) =>{
response.should.have.status(200)
response.body.should.be('string')
done()
})
})
})
describe('GET /api/chow/users', () => {
it('it should GET all the users', (done) => {
chai.request(user)
.get("/api/chow/users")
.end((err, response) =>{
response.should.have.status(200)
response.should.be.a('array')
done()
})
})
})
})
函数式编程
幕布斯7119047
大话西游666
相关分类