Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support runtime delay functions #1281

Merged
merged 4 commits into from
Apr 2, 2024

Conversation

huwshimi
Copy link
Contributor

Status

READY

Description

Add support for generating mock delay times at runtime.

Fixes: #1279

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

  1. In root run yarn build.
  2. cd samples/react-query/basic.
  3. Open orval.config.ts and replace mock: true, with:
      mock: {
        type: 'msw',
        delay: () => (process.env.NODE_ENV === 'test' ? 10 : 1000),
        delayCalcRuntime: true,
      },
  1. Run yarn generate-api.
  2. Open src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts.
  3. See that the delays are now await delay((() => (process.env.NODE_ENV === 'test' ? 10 : 1e3))());

@melloware melloware added the mock Related to mock generation label Mar 25, 2024
@soartec-lab
Copy link
Collaborator

Thank you for made this PR. I'll review it.

Copy link
Collaborator

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

@huwshimi

Thank you for your great work. I have made some comments, please check them.

docs/src/pages/reference/configuration/output.md Outdated Show resolved Hide resolved
packages/core/src/types.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

Thanks!

@soartec-lab
Copy link
Collaborator

@melloware
I think it's good, but could you review it again?

@melloware melloware merged commit ada6a19 into anymaniax:master Apr 2, 2024
0 of 2 checks passed
@melloware melloware added this to the 6.27.0 milestone Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mock Related to mock generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow delay to be configurable for tests
3 participants