Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript RTL&x27;s TypeError:_react2.screen.getAllBy不是函数_Javascript_Reactjs_Testing_Jestjs_React Testing Library - Fatal编程技术网

Javascript RTL&x27;s TypeError:_react2.screen.getAllBy不是函数

Javascript RTL&x27;s TypeError:_react2.screen.getAllBy不是函数,javascript,reactjs,testing,jestjs,react-testing-library,Javascript,Reactjs,Testing,Jestjs,React Testing Library,在我的项目中,我成功地使用了@testing library/react中的render和screen,但是每次我使用screen.getAllBy或screen.getByRole或getByText以外的任何东西时,我都会遇到这样的错误。其中一个是, typeerror: _react2.screen.getAllBy is not a function 这是在使用screen.getAllBy时发生的 我的进口包括, import React from 'react'; import {

在我的项目中,我成功地使用了
@testing library/react
中的
render
screen
,但是每次我使用
screen.getAllBy
screen.getByRole
getByText
以外的任何东西时,我都会遇到这样的错误。其中一个是,

typeerror: _react2.screen.getAllBy is not a function
这是在使用
screen.getAllBy
时发生的

我的进口包括,

import React from 'react';
import { render, screen } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom;
import TestComponent from './TestComponent';
我是否缺少导入或我的代码有问题

it (`Testing Component`, () => { 
  render(<BrowserRouter><TestComponent /></BrowserRouter>
  expect(screen.getAllBy('li')).toBeInTheDocument();
});
it(`Testing Component`,()=>{
渲染(
expect(screen.getAllBy('li')).toBeInTheDocument();
});

getAllBy
只是查询的变体之一。完整的查询将是
GetAllByBelText、getAllByRole
等。检查关于查询。

之前阅读了几次文档。并行思考过多的最终结果。我很惊讶错过了如此琐碎的细节。--