Skip to content

Instantly share code, notes, and snippets.

@marta-pinkowska
Last active February 20, 2023 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marta-pinkowska/5c6abaeb422dc7b6dbd69004068a6aa2 to your computer and use it in GitHub Desktop.
Save marta-pinkowska/5c6abaeb422dc7b6dbd69004068a6aa2 to your computer and use it in GitHub Desktop.
// __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