Skip to content

Instantly share code, notes, and snippets.

@hellotunmbi
Last active December 18, 2019 18:15
Show Gist options
  • Save hellotunmbi/b3e6b8b9ca3566c8140659fdb6d71a8c to your computer and use it in GitHub Desktop.
Save hellotunmbi/b3e6b8b9ca3566c8140659fdb6d71a8c to your computer and use it in GitHub Desktop.
// movies.spec.js
...
// Testing the POST /movies endpoint
it("tests the post new movies endpoint and returns as success message", async () => {
const response = await supertest(app).post('/movies').send({
title: 'New Movie',
synopsis: 'Synopsis of the new movie',
rating: 'PG'
});
expect(response.status).toBe(200);
expect(response.body.status).toBe('success');
expect(response.body.message).toBe('Movies Saved Successfully.');
});
// This is run after
afterEach(async () => {
await Movies.deleteOne({
title: 'New Movie'
})
})
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment