I have a similar problem to https://github.com/airbnb/enzyme/issues/1525
but it is dosen't work https://github.com/airbnb/enzyme/issues/1525#issuecomment-373008462
my code:
describe('test', () => {
it('test', async () => {
document.body.innerHTML = '<div id="test"></div>'
const wrapper1 = mount(<div style={{ height: '10px' }}>0</div>, {
attachTo: document.querySelector('#test')
})
const dom1 = wrapper1.getDOMNode()
//dom1 .clientHeight => 0
})
})
dom1 .clientHeight = 0
dom1 .clientHeight = 10
windows
Are you using jsdom? I believe this is a known limitation of jsdom - the clientHeight is zero because it's not actually visible.
I know , but in some scenarios, I just want to test the height of a node, for example, I have some image, the height of each image is fixed, I want to find the wrong size image when all pictures have same width .
Then it seems like you'd need to test it in an actual browser, and not using jsdom - this doesn't seem related to enzyme.
All right锛孧aybe I should change the way to solve this problem.
FYI jsdom/jsdom#135 is the relevant issue in jsdom where offsetWidth/Height, etc. are not yet supported. There is a kludgy workaround presented in that thread that seems to have helped some people, but I say there be demons in that approach.
Most helpful comment
All right锛孧aybe I should change the way to solve this problem.