How in Jest testing to match a string which contains a "/" and gives a syntax error
You need to escape the special characters (i.e. /
, (
and )
) in your regular expression with a backslash (i.e. \
).
Change it to:
expect(screen.getByText(/26 Aug 2021, 8:06 \(Europe\/Berlin\)\)).toBeVisible();
A decent explanation of escaping special characters can be found here. The regex can be seen in action here.