@testing-library/user-event version: 12.0.11Relevant code or config
import React from "react";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
describe("test", () => {
it("does not throw on div type", async () => {
render(<div tabIndex={0}>foo</div>);
try {
screen.getByText("foo").focus();
await userEvent.type(screen.getByText("foo"), " ");
} catch (e) {
expect(e).toEqual("");
}
});
});
Reproduction repository:
https://codesandbox.io/s/agitated-meitner-3zhxf?file=/src/user-event.test.js
Problem description:
I assume that userEvent.type is the preferred way to simulate a keydown + keyup event on focused elements. If that is not the case, please consider this issue as irrelevant 馃槄
Using type on a element without value should not throw an error.
Suggested solution:
value propertyvalueReminder: Add suggestions from https://github.com/testing-library/user-event/pull/409
Hi @visualjerk,
I think the suggested solution is good. I'm worried about the challenges that contenteditable will present to us in the future, but if you just want to fire events at a div I think that's fine :)
@visualjerk Do you want to work on this PR 馃槂 ?
Sure, I will 馃槃
:tada: This issue has been resolved in version 12.0.14 :tada:
The release is available on:
npm package (@latest dist-tag)Your semantic-release bot :package::rocket:
Most helpful comment
Sure, I will 馃槃