Friday 24 April 2020

Jest testing order inside a single testing file

Here's my testdescribe("bookmark route test", () => {describe("GET => /api/bookmarks", () => {it("should work", async () => {const response = await request.get("/api/bookmarks");expect(response.status).toEqual(200);expect(response.body).toHaveLength(0);});});describe("POST => /api/bookmark", () => {it("should create bookmark", async () => {const response = await request.post("/api/bookmarks").send({name: randomStr(randomInt(5, 12)),criteria: {searchWord: randomStr(randomInt(5, 12))}});expect(response.status).toEqual(200);});it("shouldn't create bookmark for invalid criteria", async () => {const response = await request.post("/api/bookmarks").send({name: randomStr(randomInt(5, 12))});expect(response.status).toEqual(400);});});describe("DELETE => /api/bookmark", () => {it("should not work for non-existent bookmark", async () => {const fakeId = randomId();const response = await request.delete(`/api/${fakeId}`);expect(response.status).toBe(404);});});});Will the first describe block run before the second and then second and so on or is it random?

Submitted April 24, 2020 at 09:05AM by undo124455

No comments:

Post a Comment