user-event icon indicating copy to clipboard operation
user-event copied to clipboard

feat: skip special character parsing

Open ph-fritsche opened this issue 3 years ago • 4 comments

@ph-fritsche Maybe add an option to skip detection of key descriptors? Something like:

userEvent.type(input, '{"foo":"bar"}', { skipSpecialCharacters: true })

Originally posted by @lynxtaa in https://github.com/testing-library/user-event/issues/584#issuecomment-800922956


An alternative might be to export this workaround as a utility:

userEvent.type(input, '{"foo":"bar"}'.replace(/[{[]/g, '$&$&'))
// would become
userEvent.type(input, escapeKeyboardInput('{"foo":"bar"}'))

ph-fritsche avatar Mar 17 '21 10:03 ph-fritsche

When typing a : or a /, it is also escaped/removed from the input value. See: https://codesandbox.io/s/user-event-type-url-sc8by?file=/src/tests/App.test.js

Escaping them with the provided regex helps with the : but not with the /

SiebeVE avatar Mar 17 '21 11:03 SiebeVE

@SiebeVE Thanks for the report. The behavior described by you is unintended. A fix is applied in #588 .

ph-fritsche avatar Mar 17 '21 11:03 ph-fritsche

Should this be closed? I noticed the original issue (#587) is.

nickmccurdy avatar Mar 18 '21 00:03 nickmccurdy

Should this be closed? I noticed the original issue (#587) is.

Nope. I've extracted that comment to a new issue because there was a bug parsing /. This issue is about adding a feature to ease escaping characters for type and keyboard.

ph-fritsche avatar Mar 18 '21 08:03 ph-fritsche