Relevant code or config
const { getAllByTestId } = createWrapper();
await flushPromises();
const dummyText = chance.string({ length: 50, alpha: true });
const field = getAllByTestId(<someid>);
// Input and Label have the same id
await userEvent.clear(field[0]);
await userEvent.type(field[0], dummyText); // <-- Here the error will be thrown
What you did:
I searched for a testId cleared the field to get rid of text that might already been in there. Type 50 characters to check that maxlength 40 works as expected for the user.
What happened:
The input triggered a cascade of clicks in an endless loop
at Object.<anonymous>.behavior.click (node_modules/@testing-library/user-event/dist/index.cjs:1387:11)
Problem description:
I used an inputelement as target, I don't know why the label is looked up and a trigger is fired, and I don't know why there seems to be a loop.
Suggested solution:
Break the infinite loop
@testing-library/user-eventversion: ^14.0.0-betaTesting Framework and version:
jest: 26.6.3
DOM Environment:
jsdom
Relevant code or config
What you did:
I searched for a testId cleared the field to get rid of text that might already been in there. Type 50 characters to check that maxlength 40 works as expected for the user.
What happened:
The input triggered a cascade of clicks in an endless loop
at Object.<anonymous>.behavior.click (node_modules/@testing-library/user-event/dist/index.cjs:1387:11)Problem description:
I used an inputelement as target, I don't know why the label is looked up and a trigger is fired, and I don't know why there seems to be a loop.
Suggested solution:
Break the infinite loop