vega-testing-library
What is userEvent api
user-event is a companion library for Testing Library that simulates user interactions by dispatching the events that would happen if the interaction took place in a browser
Why we need to extending user event api
Currently, when using the test library for interactive operations, it becomes very troublesome and cumbersome to find triggerable elements because Shadow DOM is used
const shadowInput: Element = document
.querySelector("vega-input")
?.shadowRoot?.querySelector("input") as Element;
userEvent.type(shadowInput, "input text");
When should use this library
Components that involve user interaction should all use this library to simplify operations and make user events simple and efficient.
Usage
import userEvent from '@testing-library/user-event';
import { createUserEventForVega } from '@heartlandone/vega-testing-library';
let user = userEvent.setup();
const userEvent = createUserEventForVega(user);
userEvent.type('vega-input', 'input text');
....