【发布时间】:2020-07-08 22:46:24
【问题描述】:
我正在尝试使用 jest 编写测试,但遇到了这个错误
Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
in td (created by TableCell)
in TableCell (created by DataTable)
in tr (created by TableExpandRow)
in TableExpandRow (created by DataTable)
in tbody (created by TableBody)
in TableBody (created by DataTable)
in table (created by Table)
in Table (created by DataTable)
in div (created by DataTable)
in div (created by TableContainer)
in TableContainer (created by DataTable)
in div (created by DataTable)
in DataTable
in Unknown
in Unknown (created by EnhancedDataTable)
in EnhancedDataTable (created by MyPage)
in div (created by MyPage)
in MyPage
27 |
28 | it('renders', () => {
> 29 | const { container } = render(<MyPage />);
MyPage 是一个返回函数的组件
<React.Fragment>
<MyHeader title={'Page Header'} />
<div className="page-content">
<EnhancedDataTable
actions={actions}
rowActions={rowActions}
headers={rowHeaders}
rowDetail={rowDetail}
rows={rowsData}
className='my-table'
/>
</div>
</React.Fragment>
我在这里错过了什么?
【问题讨论】:
标签: reactjs jestjs react-testing-library