test(frontend): migrate MSW in Storybook to v2 (#13195)
This commit is contained in:
parent
82c34f7f45
commit
5299d17060
14 changed files with 140 additions and 143 deletions
|
|
@ -286,18 +286,17 @@ export const argTypes = {
|
|||
min: 1,
|
||||
max: 4,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Also, you can use msw to mock API requests in the storybook. Creating a `MyComponent.stories.msw.ts` file to define the mock handlers.
|
||||
|
||||
```ts
|
||||
import { rest } from 'msw';
|
||||
import { HttpResponse, http } from 'msw';
|
||||
export const handlers = [
|
||||
rest.post('/api/notes/timeline', (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.json([]),
|
||||
);
|
||||
http.post('/api/notes/timeline', ({ request }) => {
|
||||
return HttpResponse.json([]);
|
||||
}),
|
||||
];
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue