Skip to content

Commit

Permalink
feat: add delay parameter to override.mock (#431)
Browse files Browse the repository at this point in the history
* feat: adding parameter to customize delay in mocks

* feat: add delay parameter to override.mock

* docs(api-reference): add delay property to example

Co-authored-by: Iorran Castro <[email protected]>
Co-authored-by: Venelin Banov <[email protected]>
  • Loading branch information
3 people authored Jun 16, 2022
1 parent 008ca98 commit 8f5e3a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/pages/reference/configuration/full-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
properties: {
'/tag|name/': () => faker.name.lastName(),
},
delay: 500
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/generators/msw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const generateMSW = async (
: '',
handler: `rest.${verb}('${route}', (_req, res, ctx) => {
return res(
ctx.delay(1000),
ctx.delay(${override?.mock?.delay || 1000}),
ctx.status(200, 'Mocked status'),${
value && value !== 'undefined'
? `\nctx.${responseType}(get${pascal(operationId)}Mock()),`
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type NormalizedOverrideOutput = {
format?: { [key: string]: unknown };
required?: boolean;
baseUrl?: string;
delay?: number;
};
header: false | ((info: InfoObject) => string[] | string);
formData: boolean | NormalizedMutator;
Expand Down

1 comment on commit 8f5e3a2

@vercel
Copy link

@vercel vercel bot commented on 8f5e3a2 Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.