TypeError: expect(...).toBeInTheDocument is not a function
> 54 | expect(screen.getByText(/alberta/i)).toBeInTheDocument();import { render,, () => {
test('It renders', () =
我在单独的测试中用一个组件测试不同的东西。我希望不必在每个单独的test中都编写render,但是下面的代码无法工作。 据我所知,清理功能会在每次测试后清除呈现的组件,所以这很好。not defined console.log(getAllByText) // not defined
}) 上面的设置会导致错误: ReferenceError: getAllByText is not define
我有一个小的React/TypeScript/GraphQL应用程序,它连接到API,获取产品,并在页面上显示它们。我正在尝试通过使用GraphQL创建一个测试,检查产品的名称是否在getByText模拟之后出现在文档中,但是我一直在获取TestingLibraryElementError: Unable to find我也尝试使用getByRole (见下文),但这给出了错误TestingLibraryElementError: