Skip to content

Instantly share code, notes, and snippets.

@rjpkuyper
Last active November 26, 2021 08:51
Show Gist options
  • Save rjpkuyper/8fde5c606b684573ab56a16d81782396 to your computer and use it in GitHub Desktop.
Save rjpkuyper/8fde5c606b684573ab56a16d81782396 to your computer and use it in GitHub Desktop.
import request from "supertest";
describe("cats (e2e)", () => {
const req = request("http://localhost:3000");
const cat = {
name: "meow",
age: 1,
breed: "foo",
};
test("create a cat", async () => {
await req
.post("/cats")
.set("Content-Type", "application/json")
.send(cat)
.expect((res) => {
expect(res.body).toMatchObject(cat);
})
.expect(201);
});
test("get a cat", async () => {
await req
.get("/cats/meow")
.expect((res) => {
expect(res.body).toMatchObject(cat);
})
.expect(200);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment