Skip to content

Instantly share code, notes, and snippets.

@frostyblok
Last active November 22, 2018 16:43
Show Gist options
  • Save frostyblok/d834a5baac3bb25dde34d5a3d93c868e to your computer and use it in GitHub Desktop.
Save frostyblok/d834a5baac3bb25dde34d5a3d93c868e to your computer and use it in GitHub Desktop.
import chai from 'chai';
import chaiHttp from 'chai-http';
import app from '../../../server';
describe('Get no article', () => {
it('should not get an article that does not exist', async () => {
const res = await chai.req(app)
.get('/api/v1/articles/234');
expect(res.status).to.be.equal(404);
expect(res.body.message).to.be.deep.equals('Article not found');
});
});
@frostyblok
Copy link
Author

This is a GET request test. It tests the API endpoint for an article with an unknown Id and ensures the appropriate error message and status code are displayed.

@Johnsonojo
Copy link

Johnsonojo commented Nov 22, 2018

Hi Korede, nice implementation. But I don't think there is a need importing data on line 4, since you're using the GET route.

@marcdomain
Copy link

Hi, I think the status in your response body (as used in your codebase) should be a text that prompts the user that the request is a failed one, not a status code.

@frostyblok
Copy link
Author

@johnson and @marcdomain thank you for the feedback, I will implement them right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment