I'm encountering an issue with the code below:
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);
});
});
Every time I execute the command:
mocha -r ts-node/register lib/tests/**/sample.spec.ts
I receive the error message:
TypeError: chai.request is not a function
I've checked other similar posts on Stack Overflow and they recommended adding:
chai.use(chaiHttp)
to solve the issue. However, as you can see, I have already included that line.
Any suggestions on how to resolve this problem?