@testing-library/react version:react version:node version:npm (or yarn) version:import React from 'react'
import { Provider } from 'react-redux'
import { combineReducers, createStore } from 'redux'
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
const initialState = {}
function reducer(state, action) {
if (typeof state === 'undefined') {
return initialState
}
// For now, don't handle any actions
// and just return the state given to us.
return state
}
it('renders welcome message', () => {
const store = createStore(combineReducers({ foos: reducer }))
const { getByText } = render(
<Provider store={store}>
<h1>hi</h1>
</Provider>
)
expect(getByText('hi')).toBeInTheDocument()
})
Tried to wire up a basic test with react, redux and rtl.
Got this error
Provider(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render noth
ing, return null.
20 | const store = createStore(combineReducers({ foos: reducer }))
21 |
> 22 | const { getByText } = render(
| ^
23 | <Provider store={store}>
24 | <h1>hi</h1>
25 | </Provider>
at reconcileChildFibers (node_modules/react-dom/cjs/react-dom.development.js:14348:23)
at reconcileChildren (node_modules/react-dom/cjs/react-dom.development.js:16762:28)
at mountIndeterminateComponent (node_modules/react-dom/cjs/react-dom.development.js:17542:5)
at beginWork (node_modules/react-dom/cjs/react-dom.development.js:18596:16)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:188:14)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:237:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:292:31)
at beginWork$1 (node_modules/react-dom/cjs/react-dom.development.js:23203:7)
at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:22157:12)
at workLoopSync (node_modules/react-dom/cjs/react-dom.development.js:22130:22)
at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:21756:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21188:7)
at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:24373:3)
at node_modules/react-dom/cjs/react-dom.development.js:24758:7
at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:21903:12)
at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:24757:5)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:24840:10)
at node_modules/@testing-library/react/dist/pure.js:86:25
at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21856:12)
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:929:14)
at render (node_modules/@testing-library/react/dist/pure.js:82:26)
at Object.<anonymous> (src/_tests_/App.test.js:22:24)
https://github.com/vicesoftware/react-redux-hooks-boilerplate/tree/testing-setupcd webappnpm installnpm testwebapp/src/_tests_/App.test.js should fail
Because I can't test apps with redux.
Hopefully get this working. I'm guessing it's a config but probably helpful to have this issue solved so others can google the fix.
Have you found a solution to this?
@DenizUgur no not yet. Are you having same issue?
Similar. It happens only when I try to generate a coverage report.
I think I saw a thread about the coverage report issue somewhere
@RyanAtViceSoftware I tested your code here and it worked, but I'm using a different version of @testing-library/react: 9.3.2. I didn't try it with 9.5.0, so I can't tell you if it's a version problem, but it's worth a try.
I'm also facing same issue
Unfortunately this has nothing to do with React Testing Library. You get the same issue when using ReactDOM directly:

My guess is there's some tooling issue going on here. Everyone who's commented here is probably experiencing some variant on the same problem. If you update to the latest of jest/babel then this should probably go away.
In any case, there's nothing we can do within React Testing Library because it's unrelated, so I'm going to close this issue. Good luck!
I'm facing the same issue with ` "@testing-library/react": "^10.2.0",
The render simply returns
<body>
<div />
</body>
Figured out that I was mocking one of the dependencies of the component. After importing the asset it fixed my issue.
Most helpful comment
I'm also facing same issue