0

I'm using @testing-library/user-event to try to type in a text box containing JSON. Sadly, it appears that because { is a special character in the string, I get an error when running this:

await userEvent.type(input, '{ "id": 1, "name": "William" }');

Expected repeat modifier or release modifier or "}" but found """ in "{ "id": 1, "name": "William" }"

I don't see any options available to tell user-event to treat text literally. Am I missing this in the documentation, or am I SOL using this technique?

Jacob
  • 77,566
  • 24
  • 149
  • 228

1 Answers1

0

After some source diving, I found that doubling up the brackets works.

await userEvent.type(input, '{{ "id": 1, "name": "William" }');
Jacob
  • 77,566
  • 24
  • 149
  • 228