Currently the uuid test mocks are hard coded. In order to ensures that every test is fresh and independent of each other, the proposed solution was to use beforeAll() to set up the mock. As jest.mock can't be used inside of the tests or inside beforeAll, jest.spyOn was used instead of jest.mock.
What was changed:
Hard-coded jest.mock were replaced with jest.spyOn inside the beforeAll().
The mocks were restored in afterAll().
Imports for uuid were changed to { v4 as uuidv4 } from 'uuid'; to allow use the jest.spyOn and consistency with the rest of Terra projects.
uuid version was locked to version 3.4.0 for consistency with the rest of Terra projects.
Testing
This change was tested using:
[x] WDIO
[x] Jest
[ ] Visual testing (please attach a screenshot or recording)
[ ] Other (please describe below)
[ ] No tests are needed
Reviews
In addition to engineering reviews, this PR needs:
[ ] UX review
[ ] Accessibility review
[ ] Functional review
Additional Details
The jest test errors are not related to current change.
The change is not user-facing and does not require a changelog entry.
Summary
Currently the uuid test mocks are hard coded. In order to ensures that every test is fresh and independent of each other, the proposed solution was to use beforeAll() to set up the mock. As jest.mock can't be used inside of the tests or inside beforeAll, jest.spyOn was used instead of jest.mock.
What was changed: Hard-coded jest.mock were replaced with jest.spyOn inside the beforeAll(). The mocks were restored in afterAll(). Imports for uuid were changed to
{ v4 as uuidv4 } from 'uuid';
to allow use the jest.spyOn and consistency with the rest of Terra projects. uuid version was locked to version 3.4.0 for consistency with the rest of Terra projects.Testing
This change was tested using:
Reviews
In addition to engineering reviews, this PR needs:
Additional Details
This PR is a part of following JIRA:
UXPLATFORM-9515