I have the following simple code
import app from '../src/app';
import * as chai from 'chai';
import chaiHttp = require('chai-http');
chai.use(chaiHttp);
const expect = chai.expect;
describe('Get /', () => {
it('Should say hi there', async () => {
const response = chai.request(app).get('/');
console.log(response);
expect(5).to.equal(5);
});
});
Each time I run
mocha -r ts-node/register lib/tests/**/sample.spec.ts
I get the following error
TypeError: chai.request is not a function
I looked at the other stackoverflow posts with the same question. They all said that adding
chai.use(chaiHttp)
should fix the problem
But, as you can see I already have that.
Any ideas?