In my React application, I'm writing a Jest testing to test if on screen I get a specific date, time, and timezone.
The test looks as it is
test('Local date time format - Europe no UK', () => {
const date = '2021-08-26T08:06:14Z';
const timezone = 'Europe/Berlin';
render(
<DateFormatter
dateTime={date}
timeZone={timezone}
variant="localDateTime"
/>,
);
expect(screen.getByText(/26 Aug 2021, 8:06 (Europe/Berlin)/)).toBeVisible();
});
The test fails with a syntax error
Test suite failed to run
SyntaxError: /Users/jake/Desktop/Trialbee/admin-frontend/src/components/DateFormatter/DateFormatter.spec.js: Invalid regular expression flag (215:54)
213 | />,
214 | );
> 215 | expect(screen.getByText(/26 Aug 2021, 8:06 (Europe/Berlin)/)).toBeVisible();
| ^
216 | });
217 |
I don't know how to make it work with the '/' as it is thinking is a regEx part but in reality, is a slash that is contained in the timezone string.