-
-
Save up1/28e012b3cdc99ab3ad249fcd62fa4b3a to your computer and use it in GitHub Desktop.
NodeJS :: Good testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| beforeAll(async () => { | |
| await seedDatabase(); | |
| }); | |
| describe("GET /users", () => { | |
| test("user exists", async () => { | |
| ... | |
| }); | |
| test("update user", async () => { | |
| ... | |
| }); | |
| test("delete user", async () => { | |
| ... | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("GET /users/:id", () => { | |
| test("returns user", async () => { | |
| // Data for testing | |
| const user = await factory.createUser({ | |
| name: "demo name", | |
| email: "demo@test.com" | |
| }); | |
| // Act | |
| const response = await request(app) | |
| .get(`/users/${user.id}`); | |
| // Assert | |
| expect(response.status).toBe(200); | |
| expect(response.body.name).toBe("demo name"); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment