Skip to content

Commit 7d80675

Browse files
committed
chore: switch to vitest browser mode?
Signed-off-by: Newton <[email protected]>
1 parent d1a72a5 commit 7d80675

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

vitest.setup.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import "@testing-library/jest-dom";
33
// If you"re using Next.js with Vite, import from @storybook/experimental-nextjs-vite
44
import { setProjectAnnotations } from "@storybook/react";
55
import { afterAll, afterEach, beforeAll } from "vitest";
6-
import { server } from "./app/mocks/node";
6+
// import { server } from "./app/mocks/node";
7+
import { worker } from "./app/mocks/browser";
78
// 👇 Import the exported annotations, if any, from the addons you're using; otherwise remove this
89
// import * as addonAnnotations from "my-addon/preview";
910
import * as previewAnnotations from "./.storybook/preview";
1011

1112
const annotations = setProjectAnnotations([previewAnnotations]);
1213

14+
/*
15+
* server side
16+
*
1317
beforeAll(async () => {
1418
// Run Storybook's beforeAll hook
1519
await annotations?.beforeAll?.();
@@ -18,3 +22,20 @@ beforeAll(async () => {
1822
});
1923
afterEach(() => server.resetHandlers());
2024
afterAll(() => server.close());
25+
*/
26+
27+
beforeAll(async () => {
28+
// Run Storybook's beforeAll hook
29+
await annotations?.beforeAll?.();
30+
await worker.start({
31+
onUnhandledRequest: "warn",
32+
});
33+
});
34+
35+
afterEach(() => {
36+
worker.resetHandlers();
37+
});
38+
39+
afterAll(() => {
40+
worker.stop();
41+
});

0 commit comments

Comments
 (0)