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

Use faker.helpers where appropriate #2087

Merged
merged 2 commits into from
Nov 6, 2024
Merged

Use faker.helpers where appropriate #2087

merged 2 commits into from
Nov 6, 2024

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Nov 4, 2024

Summary

There are faker.helpers that we are not leveraging in our tests, instead using proprietary workarounds. This changes the following throughout the project:

Object keys

// from
faker.helpers.arrayElement(Object.keys(...))
// to
faker.helpers.objectKey(...)

Enum values

// from
faker.helpers.arrayElement(Object.values(...))
// to
faker.helpers.enumValue(...)

Array samples

// from
Array.from(
  { length: faker.number.int({ min: n, max: m }) },
  () => builder(),
);
// to
faker.helpers.multiple(
  () => builder(),
  { count: { min: n, max: m } },
);

@iamacook iamacook self-assigned this Nov 4, 2024
@iamacook iamacook requested a review from a team as a code owner November 4, 2024 14:46
@iamacook iamacook marked this pull request as draft November 4, 2024 15:22
@iamacook iamacook marked this pull request as ready for review November 5, 2024 09:17
@PooyaRaki PooyaRaki self-requested a review November 6, 2024 08:59
@iamacook iamacook merged commit 1a84d6b into main Nov 6, 2024
20 checks passed
@iamacook iamacook deleted the faker-methods branch November 6, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants