ResponseRateChart tests failing locally with non-US system language
Running make qa
there are two frontend ResponseRateChart tests that are failing locally:
FAIL src/components/report_widgets/tests/ResponseRateChart.test.tsx
● Bar chart › Should render a bar chart left to right
expect(received).toContain(expected) // indexOf
Expected substring: "Nov 9, 2022Nov 10, 2022Nov 11, 2022Nov 12, 2022"
Received string: "9 Nov 202210 Nov 202211 Nov 202212 Nov 20220%20%40%60%80%100%"
38 | window.TEXT_DIRECTION = "ltr";
39 | render(<Container rates={dummyResponseRates()} />);
> 40 | expect(screen.getByTestId("beep").textContent).toContain(
| ^
41 | "Nov 9, 2022Nov 10, 2022Nov 11, 2022Nov 12, 2022"
42 | );
43 | });
at Object.<anonymous> (src/components/report_widgets/tests/ResponseRateChart.test.tsx:40:52)
● Bar chart › Should render a bar chart right to left
expect(received).toContain(expected) // indexOf
Expected substring: "Nov 12, 2022Nov 11, 2022Nov 10, 2022Nov 9, 2022"
Received string: "12 Nov 202211 Nov 202210 Nov 20229 Nov 20220%20%40%60%80%100%"
45 | window.TEXT_DIRECTION = "rtl";
46 | render(<Container rates={dummyResponseRates()} />);
> 47 | expect(screen.getByTestId("beep").textContent).toContain(
| ^
48 | "Nov 12, 2022Nov 11, 2022Nov 10, 2022Nov 9, 2022"
49 | );
50 | });
at Object.<anonymous> (src/components/report_widgets/tests/ResponseRateChart.test.tsx:47:52)
It seems that since the translations are not setup during test that i18n.language is undefined
therefore a fallback to my system language en-GB
but the tests expect en-US
data format.
I couldn't quite find a jest mock solution that worked so some suggestions would be useful here.