How to use the @testing-library/vue.fireEvent function in @testing-library/vue

To help you get started, we’ve selected a few @testing-library/vue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / testing-library__vue / testing-library__vue-tests.ts View on Github external
lib.queryByText(elem, /some text/, {exact: true, trim: false, collapseWhitespace: true, normalizer: x => x, selector: '*'}); // $ExpectType HTMLElement | null
lib.queryAllByText(elem, "foo"); // $ExpectType HTMLElement[]
lib.queryAllByText(elem, /some text/, {exact: true, trim: false, collapseWhitespace: true, normalizer: x => x, selector: '*'}); // $ExpectType HTMLElement[]
lib.findByText(elem, "foo"); // $ExpectType Promise
lib.findByText(elem, /some text/, {exact: true, trim: false, collapseWhitespace: true, normalizer: x => x, selector: '*'}); // $ExpectType Promise
lib.findAllByText(elem, "foo"); // $ExpectType Promise
lib.findAllByText(elem, /some text/, {exact: true, trim: false, collapseWhitespace: true, normalizer: x => x, selector: '*'}); // $ExpectType Promise

// Reexports createEvent from dom-testing-library
lib.createEvent.click(elem); // $ExpectType Event
lib.createEvent.click(elem, {foo: "bar"}); // $ExpectType Event
lib.createEvent.keyDown(elem); // $ExpectType Event
lib.createEvent.mouseEnter(elem); // $ExpectType Event

// Changes fireEvent to be asynchronous
lib.fireEvent(elem, new Event('change')); // $ExpectType Promise
lib.fireEvent.click(elem); // $ExpectType Promise
lib.fireEvent.click(elem, {foo: "bar"}); // $ExpectType Promise
lib.fireEvent.keyDown(elem); // $ExpectType Promise
lib.fireEvent.mouseEnter(elem); // $ExpectType Promise

// Adds update() function
lib.fireEvent.update(input, "foo"); // $ExpectType Promise
lib.fireEvent.update(select, "bar"); // $ExpectType Promise
lib.fireEvent.update(textarea, "some\ntext"); // $ExpectType Promise
lib.fireEvent.update(option); // $ExpectType Promise

// Adds touch() function
lib.fireEvent.touch(elem); // $ExpectType Promise

// Reexports async functions from dom-testing-library
lib.wait(); // $ExpectType Promise
github testing-library / vue-testing-library / src / __tests__ / fire-event.js View on Github external
test('calling `fireEvent` directly works too', async () => {
  const {getByRole, emitted} = render(Button)

  const button = getByRole('button')

  await fireEvent(button, new Event('click'))

  expect(emitted()).toHaveProperty('click')
})