Skip to content

Add support for random delay in ra-data-fakerest#11143

Open
dreglad wants to merge 1 commit intomarmelab:nextfrom
dreglad:ra-data-fakerest-random_delay
Open

Add support for random delay in ra-data-fakerest#11143
dreglad wants to merge 1 commit intomarmelab:nextfrom
dreglad:ra-data-fakerest-random_delay

Conversation

@dreglad
Copy link

@dreglad dreglad commented Feb 1, 2026

Problem

Previously, ra-data-fakerest only supported a fixed delay (in milliseconds). This made it difficult to simulate more realistic, variable network conditions during development or end-to-end testing.

Solution

This PR enhances the delay parameter of the fakeDataProvider to support random ranges:

type Delay = number | boolean | { min?: number; max?: number };

number: Remains supported for fixed delays (backward compatible).
boolean: Passing true enables a default random delay between 500ms and 1500ms.
object: Passing { min: number, max: number } allows setting a custom random range.

How To Test

Added a parameterized test to packages/ra-data-fakerest/src/index.spec.ts to ensure all scenarios are covered with no breaking changes.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
    • Not a bugfix, but a backwards-compatible new feature.
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
    • Not applicable for this data provider change; behavior is fully verified via unit tests.
  • The documentation is up to date
    • Updated README.md with examples

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

Great! Would you mind changing the PR target to next instead of master? master is only for bug fixes, new features come to next.

@fzaninotto fzaninotto changed the base branch from master to next February 16, 2026 09:37
@fzaninotto fzaninotto changed the base branch from next to master February 16, 2026 09:38
@fzaninotto fzaninotto force-pushed the ra-data-fakerest-random_delay branch from e70724a to 7932f37 Compare February 16, 2026 09:41
@fzaninotto fzaninotto changed the base branch from master to next February 16, 2026 09:41
@fzaninotto fzaninotto force-pushed the ra-data-fakerest-random_delay branch from 7932f37 to 44e4e48 Compare February 16, 2026 09:43
@fzaninotto
Copy link
Member

i rebased your PR on next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants