Skip to content

Commit

Permalink
fix: test fail due to msw error not handled
Browse files Browse the repository at this point in the history
  • Loading branch information
hussedev committed Oct 14, 2024
1 parent bb72190 commit 6272bf8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/task-list/task-list.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ import { TaskList } from "./task-list";
import { TaskListProvider } from "./task-list-context";
import { taskListHandler, taskListHandlerWithError } from "../../mocks/handlers";

const todosLoader = async () => {
try {
const tasks = await fetch("https://jsonplaceholder.typicode.com/todos").then((response) =>
response.json(),
);
return { tasks };
} catch (error) {
return { tasks: [] };
}
};

const meta = {
title: "Components/TaskList",
component: TaskList,
loaders: [
async () => {
const tasks = await fetch("https://jsonplaceholder.typicode.com/todos").then((response) =>
response.json(),
);

return { tasks };
},
],
loaders: [todosLoader],
decorators: [
(Story, { loaded }) => {
return (
Expand Down

0 comments on commit 6272bf8

Please sign in to comment.