| 12345678910111213141516171819202122 |
- import { setupPolly } from "setup-polly-jest";
- import "whatwg-fetch";
- const getPost = async id => {
- const response = await fetch(`/posts/${id}`);
- const json = await response.json();
- return Object.assign(json, { ok: response.ok, status: response.status });
- };
- describe("user api test", () => {
- let context = setupPolly({
- /* default configuration options */
- });
- test("should have polly running with `test`", async () => {
- const { server } = context.polly;
- server.get("/posts/*path").intercept((req, res) => {
- res.send(1);
- });
- expect(await getPost(1)).toHaveProperty("id", 1);
- });
- });
|