Skip to content

Commit 7d0f74c

Browse files
authored
Merge pull request #448 from DialmasterOrg/fix/storybook-msw-worker-setup
fix: Storybook failing to load/update docs
2 parents a8dc3e3 + 7014f8e commit 7d0f74c

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

client/.storybook/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const config = {
66
'../src/**/__tests__/**/*.story.@(js|jsx|mjs|ts|tsx|mdx)',
77
],
88
addons: ['@storybook/addon-a11y', '@storybook/addon-links'],
9+
staticDirs: ['../public'],
910
framework: {
1011
name: '@storybook/react-vite',
1112
options: {},

client/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"typescript": "5.9.3"
2929
},
3030
"scripts": {
31+
"postinstall": "npx msw init public/ --save",
3132
"dev": "vite",
3233
"start": "vite",
3334
"build": "vite build",

client/src/components/__tests__/ChannelManager.story.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const meta: Meta<typeof ChannelManager> = {
1616
parameters: {
1717
layout: 'fullscreen',
1818
},
19+
decorators: [
20+
(Story) => (
21+
<MemoryRouter>
22+
<Story />
23+
</MemoryRouter>
24+
),
25+
],
1926
};
2027

2128
export default meta;

client/src/components/__tests__/VideosPage.story.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import type { Meta, StoryObj } from '@storybook/react';
33
import { expect, userEvent, within, waitFor } from 'storybook/test';
44
import { http, HttpResponse } from 'msw';
5+
import { MemoryRouter } from 'react-router-dom';
56
import VideosPage from '../VideosPage';
67

78
const meta: Meta<typeof VideosPage> = {
@@ -13,6 +14,13 @@ const meta: Meta<typeof VideosPage> = {
1314
parameters: {
1415
layout: 'fullscreen',
1516
},
17+
decorators: [
18+
(Story) => (
19+
<MemoryRouter>
20+
<Story />
21+
</MemoryRouter>
22+
),
23+
],
1624
};
1725

1826
export default meta;

docs/DEVELOPMENT.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,19 @@ The Vite dev server will proxy API and WebSocket requests to the backend at port
114114

115115
Use Storybook to develop and document components in isolation.
116116

117+
**Prerequisites:** Complete Step 2 (Build Development Environment) first, or at minimum install client dependencies:
118+
```bash
119+
cd client && npm install
120+
```
121+
122+
This automatically generates the MSW (Mock Service Worker) file needed for API mocking in stories.
123+
117124
```bash
118125
# Start Storybook Server
119126
npm run storybook
120127
```
121128

122-
Storybook runs on http://localhost:6006. Story validation is done via Jest tests (see `client/src/tests/storybook_coverage.test.js`).
129+
Storybook will open automatically in your browser. Story validation is done via Jest tests (see `client/src/tests/storybook_coverage.test.js`).
123130

124131
### 6. Access the Application
125132

0 commit comments

Comments
 (0)