-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Though I set handler that handler doesn't work and 404 error returns.
I made sure logging [MSW] Mocking enabled. on console.
I set various handler, get method, post method, full path url, relative path url, handler on preview.ts, handler on each component, but it doesn't change anything.
when I set onUnhandledRequest event, this event always emits.
initialize({
onUnhandledRequest: ({ method, url }) => {
console.log(`MSW:onUnhandledRequest [method] ${method}, [url] ${url}`);
},
});Is that because next.js specific issue?
I called getWorker() on my storybook component, but its data currentHandlers: Array(0) expresses no handlers set.
useEffect(() => {
console.log(getWorker());
fetch("/get_config")
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
});
}, []);my preview.ts is
const preview: Preview = {
parameters: {
msw: {
handlers: [
rest.get("/get_config", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({ jsonrpc: "2.0", id: 1, result: JSON.parse("{}") }),
);
}),
rest.get("http://localhost:6006/get_config", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({ jsonrpc: "2.0", id: 1, result: JSON.parse("{}") }),
);
}),
rest.post("/get_config", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({ jsonrpc: "2.0", id: 1, result: JSON.parse("{}") }),
);
}),
rest.post("http://localhost:6006/get_config", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({ jsonrpc: "2.0", id: 1, result: JSON.parse("{}") }),
);
}),
],
},
loaders: [mswLoader],
},
};dependency
"@storybook/addon-essentials": "^7.4.0",
"@storybook/addon-interactions": "^7.4.0",
"@storybook/addon-links": "^7.4.0",
"@storybook/blocks": "^7.4.0",
"@storybook/nextjs": "^7.4.0",
"@storybook/react": "^7.4.0",Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels