Last active
February 20, 2023 17:26
-
-
Save marta-pinkowska/5c6abaeb422dc7b6dbd69004068a6aa2 to your computer and use it in GitHub Desktop.
This file contains 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
// __tests__/FancyPage.test.js | |
import { setupServer } from "msw/node"; | |
import { FancyComponentWithAPICall } from "../FancyComponentWithAPICall"; | |
const server = setupServer( | |
rest.get("https://fancy-app.com/getSomeData", (req, res, ctx) => { | |
return res(ctx.json({ data: "return this string" })); | |
}) | |
); | |
describe("<FancyComponentWithAPICall />", () => { | |
beforeAll(() => server.listen()); | |
afterAll(() => server.close()); | |
test("displays data from backend", async () => { | |
// Render components, perform requests, receive mocked responses. | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment