testing-library/no-promise-in-fire-event

January 5, 2026 ยท View on GitHub

๐Ÿ“ Disallow the use of promises passed to a fireEvent method.

๐Ÿ’ผ This rule is enabled in the following configs: badge-angular angular, badge-dom dom, badge-marko marko, badge-react react, badge-svelte svelte, badge-vue vue.

Methods from fireEvent expect to receive a DOM element. Passing a promise will end up in an error, so it must be prevented.

Examples of incorrect code for this rule:

import { screen, fireEvent } from '@testing-library/react';

// usage of unhandled findBy queries
fireEvent.click(screen.findByRole('button'));

// usage of unhandled promises
fireEvent.click(new Promise(jest.fn()));

// usage of references to unhandled promises
const promise = new Promise();
fireEvent.click(promise);

const anotherPromise = screen.findByRole('button');
fireEvent.click(anotherPromise);

Examples of correct code for this rule:

import { screen, fireEvent } from '@testing-library/react';

// usage of getBy queries
fireEvent.click(screen.getByRole('button'));

// usage of awaited findBy queries
fireEvent.click(await screen.findByRole('button'));

// usage of references to handled promises
const promise = new Promise();
const element = await promise;
fireEvent.click(element);

const anotherPromise = screen.findByRole('button');
const button = await anotherPromise;
fireEvent.click(button);

Further Reading