Skip to content

Instantly share code, notes, and snippets.

@marta-pinkowska
Created September 26, 2022 13:30
Show Gist options
  • Save marta-pinkowska/f8bd761b4db21f1248423bdbfc60b4c0 to your computer and use it in GitHub Desktop.
Save marta-pinkowska/f8bd761b4db21f1248423bdbfc60b4c0 to your computer and use it in GitHub Desktop.
// src/FancyHomepageFeature/msw/mswHandlers.js
import { rest } from 'msw';
// import the server created for the entire test suite
// this mock server includes commonMswHandlers
import { server } from '../tools/jest/server';
const homeHandlers = [
rest.get('https://fancy-app.com/homepage-data', (req, res, ctx) => {
return res(
ctx.json({
contents: [
{
banner: 'Fancy Banner'
},
],
})
);
}),
];
export const setupHomeHandlers = () => {
server.use(...homeHandlers);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment