I'm trying to write tests for my simple React App that creates a UI for a dog Shelter using API etc. I have imported the modules shown below and ran the following command
npm install jest-dom react-testing-library --save-dev
However describe, it and expect are all underlined with the error "cannot find name 'describe' Do you need to install type definitions for a test runner? Try npm i @types/jest or npm i @types/mocha". I tried both and no success.
import "react-testing-library/cleanup-after-each";
import "jest-dom/extend-expect";
import * as React from "react";
import PetCard from "./PetCard";
import Pet from "./Pet";
import { render } from "react-testing-library";
const petMock = {
id: "225c5957d7f450baec75a67ede427e9",
name: "Fido",
status: "available",
kind: "dog",
breed: "Labrador",
} as Pet;
describe("PetCard", () => {
it("should render the name", () => {
const { getByText } = render(<PetCard pet={petMock} />);
expect(getByText("Fido")).toBeInTheDocument();
});
});
Any advice I can do to stop the "cannot find name 'describe' error would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire