MSW ã使ã£ã jest ã®ãã¹ãã«ã¤ãã¦ãå¼æ°ãªã©ã®æ¤æ»ãé¢åã¨ããè¨äºãæè¦ããã®ã§ãããåæ§ã«ã¢ããã¼ãã模索ããã¦ããæ¹ãããã£ãããã°åèã«ãã¨æãè¨äºã«ãã¾ãããçè ã¯æ®æ®µä»¥ä¸ã®æ§ã«ãserver.useå ã«jest.fnãä»è¾¼ã¿ãã¹ããã¦ãã¾ããä¾ãã° API ã2åå¼ã°ãããã¨ãæ¤è¨¼ããå ´åã次ã®æ§ã«ãªãã¾ãã const server = setupMockServer(...handlers); describe("API call ã®æ¤è¨¼", () => { const mockFn = jest.fn(); beforeEach(() => { server.use( rest.get("/path/to/api", async (req, res, ctx) => { mockFn();ã// <- here return res(ctx.json({}));
{{#tags}}- {{label}}
{{/tags}}