'Is chai HTTP considered unit testing or integration testing?
The project I am working on has Cloud Functions written in user-controller.ts, and I am writing tests for these cloud functions using chai HTTP functions. Here's a sample of a test I am writing
it('should success and get all users', (done) => {
chai.request(myFunctions.qa)
.get('/getAllUsers')
.set('x-api-key', API_KEY)
.set('user-token', AdminToken)
.set('content-type', 'application/json')
.end((err, res) => {
res.should.have.status(200);
res.body.should.be.a('object').with.property('status', true);
res.body.should.have.a.property('data');
const data = res.body.data;
expect(data).to.be.an('object');
if (Object.keys(data).length > 0) {
Object.values(data).map((user: any) => {
expect(user).to.have.property('firstName');
expect(user).to.have.property('lastName');
});
}
done();
});
});
I would like to know if this test is considered a unit test or integration test? If it's considered an integration test, how am I supposed to change it into a unit test?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
