我使用“create React App”创建了一个 React.js 应用程序,并且我正在学习运行测试。
expect().toBeInTheDocument
如果我不导入,为什么在下面的代码中可以使用@testing-library/jest-dom
?
import {render, screen} from "@testing-library/react";
import Greeting from "./Greeting";
test("renders Hello World as a text", () => {
render(<Greeting/>);
const helloWorld = screen.getByText('Hello World');
expect(helloWorld).toBeInTheDocument
});