gaearon / gaearon/react-hot-loader
Enzyme fails to return text or html when shallow rendering
- Dominant language
- JavaScript
- Stars
- 12.2k
- Forks
- 775
- PR merge metrics
- No merged PRs in 30d
Description
If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.
### Description
What you are reporting:
When shallow rendering in enzyme, `text` and `html` functions return null strings.
I tried a few things when reproducing. First, this works fine in v3. Merely upgrading to v4 without changing any other code is can cause this issue. I tried removing all React Hot Loader code and nothing changed.
If I do a `mount` instead of `shallow` render, it works fine which makes me think something's getting rendered in between.
### Expected behavior
What you think should happen:
`wrapper.text()` should have the value `hi` and any other text in the component.
### Actual behavior
What actually happens:
`wrapper.text()` returns a null string `''`.
### Environment
React Hot Loader version: 4.0.0
Run these commands in the project folder and fill in their results:
1. `node -v`: v8.9.4
2. `yarn-v`: 1.3.2
Then, specify:
1. Operating system: Windows 10 64-bit
2. Browser and version: Chrome 66.0.3359.33 beta 64-bit
### Reproducible Demo
#### .babelrc
```json
{
"plugins": [
"add-react-displayname",
"extract-hoc/babel",
"react-hot-loader/babel",
"transform-class-properties",
"transform-object-rest-spread",
"transform-runtime",
],
"presets": [
[
"env", {
"modules": false,
}
],
"react",
],
}
```
#### entrypoint.js
```js
import Adapter from 'enzyme-adapter-react-16'
import React from 'react'
import { configure } from 'enzyme'
import { shallow } from 'enzyme'
// Setup Enzyme for React 16
configure({ adapter: new Adapter() })
const TestComponent = () =>
const wrapper = shallow()
console.log(
'Should be true:',
wrapper.text() === 'hi'
)
```
Contributor guide
Assessment
This issue has not been assessed yet.