Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
UnhandledPromiseRejection error in React test

I am doing test on the React+Typescript using React Testing Library and Jest. This test could not run at all with the following error:

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: Cannot read properties of undefined (reading 'json')".] { code: 'ERR_UNHANDLED_REJECTION' }

Here is my test. Please help my to fix it.

const renderComponent = (): RenderResult => {
  return render(
      <List />,
    {}
  );
};

const { getByTestId, findByTestId, findByText } = screen;

const renderElements = (): any => {
  const component = renderComponent();
  return {
    deleteIcon: screen.getByTestId("delete-icon"),
    dialogPopup: screen.getByTestId("dialog-popup"),
    component,
  };
};

describe("When click on Delete icon", () => {
  it("should show Dialog Confirmation Popup", () => {
    const { deleteIcon, dialogPopup } = renderElements();
    userEvent.click(deleteIcon);
    expect(dialogPopup).toBeInTheDocument();
  });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!