I created some basic tests and followed the getting started guide on Jests website, but toHaveAttribute is not a function apparently
import React from "react";
import { fireEvent, render } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { App } from "../App";
test("allows users to add items to their list", () => {
const { getByText, getByLabelText, getByTestId } = render(<App />);
const input = getByLabelText("What needs to be done?");
userEvent.type(getByTestId("email"), "Hello World!")
expect(getByTestId("email")).toHaveAttribute("value", "Hello, World!")
})
TypeError: expect(...).toHaveAttribute is not a function
10 | const input = getByLabelText("What needs to be done?");
11 | userEvent.type(getByTestId("email"), "Hello World!")
> 12 | expect(getByTestId("email")).toHaveAttribute("value", "Hello, World!")
| ^
13 | })
I followed the tutorial exactly so im unsure why this is happening.
Aucun commentaire:
Enregistrer un commentaire