fix: failing tests locally with non-en-US locale
Running frontend tests locally with en-GB
system locale resulted in
failing ResponseRateChart tests due to i18n.language
being undefined
so falling back to system locale.
Fixed by adding a fallback resources
in i18n
init to ensure i18n.language
is
set to en
.
Supporting information
- Jira ticket: BB-7336
- GitLab issue: #99 (closed)
Merge deadline
"None"
Testing instructions
- Verify failing test locally with
master
branch, then with PR branch using LANG prefix:
LANG=en_GB CI=true npm test --prefix frontend frontend/src/components/report_widgets/tests/ResponseRateChart.test.tsx
LANG=en_US CI=true npm test --prefix frontend frontend/src/components/report_widgets/tests/ResponseRateChart.test.tsx
- Since this modifies the i18n init config, needed to double-check that the translations still worked. Tested by appending either of these query param
lng=ar
to URL:
localhost:8000/?lng=ar
To reset language run following in browser console and refresh:
delete localStorage.i18nextLng
Edited by Calum Lind