I'm trying to test when the user enters some value to the input, and then it fetches some options from API to show and then I select one option out of them then form should have those values.
When I ran npm test one test fails for some reason.
My code test code:
import "@testing-library/jest-dom/extend-expect";
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import selectEvent from "react-select-event";
import SkillSelect from "../SkillSelect";
test("React select", async () => {
render(<SkillSelect data={[]} index="1" id="2" />);
expect(screen.getByTestId("form")).toHaveFormValues({});
fireEvent.change(screen.getByLabelText("Skills"), {
target: { value: "java" },
});
await selectEvent.select(screen.getByLabelText("Skills"), "java");
expect(screen.getByRole("form")).toHaveFormValues({
label: "Javascript",
value: "javascript",
});
});
Error message:

Anyone please help me with this!