Skip to content

fix: failing tests locally with non-en-US locale

Calum Lind requested to merge cas.dev/listaflow:fix/tests-fail-en-GB into master

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

Merge deadline

"None"

Testing instructions

  1. 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
  1. 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

Merge request reports