Skip to content

Commit

Permalink
storybook 起動時に mock service worker を起動するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kuramapommel committed Aug 24, 2024
1 parent c22e018 commit 006e8a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sample/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Preview } from '@storybook/react'
import { initialize, mswLoader } from 'msw-storybook-addon'
import '../src/index.css'
import { handlers } from '../src/testing/mocks/handlers'

const preview: Preview = {
parameters: {
Expand All @@ -9,7 +11,15 @@ const preview: Preview = {
date: /Date$/i,
},
},
msw: {
handlers: [...handlers],
},
},
// Provide the MSW addon loader globally
loaders: [mswLoader],
}

// Initialize MSW
initialize()

export default preview
1 change: 1 addition & 0 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"husky": "^9.1.4",
"jsdom": "^24.1.0",
"msw": "^2.3.1",
"msw-storybook-addon": "^2.0.3",
"postcss": "^8.4.40",
"prettier": "^3.3.2",
"storybook": "^8.2.7",
Expand Down
9 changes: 8 additions & 1 deletion sample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5095,7 +5095,7 @@ is-negative-zero@^2.0.3:
resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.3.tgz#ced903a027aca6381b777a5743069d7376a49747"
integrity sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==

is-node-process@^1.2.0:
is-node-process@^1.0.1, is-node-process@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/is-node-process/-/is-node-process-1.2.0.tgz#ea02a1b90ddb3934a19aea414e88edef7e11d134"
integrity sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==
Expand Down Expand Up @@ -5704,6 +5704,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

msw-storybook-addon@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/msw-storybook-addon/-/msw-storybook-addon-2.0.3.tgz#6a9ccf19f89ec9dde1d17e4a3be71d93b42e857a"
integrity sha512-CzHmGO32JeOPnyUnRWnB0PFTXCY1HKfHiEB/6fYoUYiFm2NYosLjzs9aBd3XJUryYEN0avJqMNh7nCRDxE5JjQ==
dependencies:
is-node-process "^1.0.1"

msw@^2.3.1:
version "2.3.2"
resolved "https://registry.yarnpkg.com/msw/-/msw-2.3.2.tgz#ea4f45b51f833fa3b2215c4093bcda28dbe25a83"
Expand Down

0 comments on commit 006e8a8

Please sign in to comment.