I want to write unit testing for Restful Endpoint, but whenever I run npm test. I get the error 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()
})
})
})
})
Aucun commentaire:
Enregistrer un commentaire