我正在使用 Redux-tool kit 来设置它。我们现在使用@testing-library/react 来设置与测试相关的设置。看官方文档的时候有个问题。
// test-utils.js
import React from 'react'
import { render as rtlRender } from '@testing-library/react'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
// Import your own reducer
import reducer from '../reducer'
function render(
ui,
{
initialState,
store = createStore(reducer, initialState),
...renderOptions
} = {}
) {
function Wrapper({ children }) {
return <Provider store={store}>{children}</Provider>
}
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions })
}
// re-export everything
export * from '@testing-library/react'
// override render method
export { render }
这部分在上面的代码部分有什么功能?
// re-export everything
export * from '@testing-library/react'
// override render method
export { render }