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

fix(msw): when use useDates, convert faker values to Date instance #1645

Conversation

soartec-lab
Copy link
Member

Status

READY

Description

fix #1517

when i use orverride.useDates with a schema that format is date or date-time will result in a type error so i fixed.

Before

birthDate and createdAt has type Date, but the value of make is a string, so type errors occurs.

export const getShowPetByIdResponseMock = (overrideResponse: Partial< Pet > = {}): Pet => ({birthDate: faker.date.past().toISOString().split('T')[0], createdAt: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse})

After

birthDate and createdAt are converted to Date instances

export const getShowPetByIdResponseMock = (overrideResponse: Partial< Pet > = {}): Pet => ({birthDate: new Date(faker.date.past().toISOString().split('T')[0]), createdAt: new Date(`${faker.date.past().toISOString().split('.')[0]}Z`), ...overrideResponse})

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

i added test case

@soartec-lab soartec-lab added bug Something isn't working msw MSW related issues labels Sep 28, 2024
@soartec-lab soartec-lab added this to the 7.2.0 milestone Sep 28, 2024
@soartec-lab soartec-lab requested review from anymaniax and melloware and removed request for anymaniax September 28, 2024 03:01
@melloware melloware merged commit 535bb65 into orval-labs:master Sep 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working msw MSW related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock: Invalid mocked values when useDates enabled
2 participants