Skip to content

Commit

Permalink
Update storybook.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tsengyushiang authored Sep 3, 2024
1 parent d3574d8 commit 46bf896
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions frontend/storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,37 @@ export const Demo = {
};
```

### Mock Websocket in stories

> Only available in the work-in-progress version `msw@next`.
- [reference](https://github.com/mswjs/msw/discussions/2010)

```javascript
import { ws } from 'msw'

const websocketHandler = (() => {
const chat = ws.link("ws://localhost:3000");
return chat.on("connection", ({ client }) => {
client.send("hello client");
client.addEventListener("message", (event) => {
console.log(event); //message from client
});
});
})();

export const Demo = {
args: {
// others props for components
},
parameters: {
msw: {
handlers: [websocketHandler],
},
},
};
```

## Setup storybook-test-runner

### Installation
Expand Down

0 comments on commit 46bf896

Please sign in to comment.