Created
September 26, 2022 13:33
-
-
Save marta-pinkowska/e0c347c0e8bc6b0baf101f799b15c37a 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
// src/FancyHomepageFeature/msw/mswHandlers.js | |
import { rest } from 'msw'; | |
import { server } from '../tools/jest/server'; | |
//... | |
export const setupFaultyHomeHandlers = () => { | |
server.use( | |
rest.get('https://fancy-app.com/homepage-data', (_req, res, ctx) => { | |
return res(ctx.status(200), ctx.json({weirdDataType: 'something went wrong'})); | |
}), | |
); | |
}; | |
export const setupFailedHomeHandlers = () => { | |
server.use( | |
rest.get('https://fancy-app.com/homepage-data', (_req, res) => { | |
return res.networkError('Failed to connect'); | |
}) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment