Unit test for get tags api endpoint in the medium.com website
describe('Test for get tags endpoint', () => { | |
it('Should return status code 200 for success', (done) => { | |
chai.request(app) | |
.get('/api/tags') | |
.set('authorization', token) | |
.end((error, response) => { | |
expect(response).to.have.status(200); | |
done(); | |
}); | |
it('should return 404 for tags not found', (done) => { | |
chai.request(app) | |
.get('/api/tags') | |
.set('authorization', token) | |
.end((error, response) => { | |
expect(response).to.have.status(404); | |
expect(response.body.error).to.equal('tags not found'); | |
done(); | |
}); | |
}); | |
}); |
This comment has been minimized.
This comment has been minimized.
Good job with your test but I think you may need to improve on the following:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Hello Joyce,
Nice work. I think you might want to consider using async/await for asynchronous calls because it helps in making code cleaner and also makes error handling easier (try/catch).
Thanks