I am working on the unit tests for react-selection-hoc and have hit a stumbling block: iOS refuses to cooperate on SauceLabs for the most basic test:
it("should return the correct page offset", () => {
if (window.____isjsdom) return
class Boohoo extends React.Component {
render() {
return (
<div style=>
<div style=>one</div>
<div style=>two</div>
<div style=>three</div>
<div style=>four</div>
</div>
)
}
}
var div = document.createElement('div');
document.body.appendChild(div)
var component = render(<Boohoo />, div);
window.scroll(20,20)
expect(document.body.scrollTop).to.equal(20)
const a = mouseMath.pageOffset('left')
const b = mouseMath.pageOffset('top')
expect(b).to.equal(20, "top should be 20")
expect(a).to.equal(20, "left should be 20")
unmountComponentAtNode(div)
})
})
The code it is testing is here:
static pageOffset(dir, win = window) {
if (dir !== 'left' && dir !== 'top') {
throw new Error(`direction must be one of top or left, was "${dir}"`)
}
let actual = win
if (win.parent) {
actual = win.parent.window
}
let offset = dir === 'left' ? 'pageXOffset' : 'pageYOffset'
offset = actual[offset] ? actual[offset] : 0
return offset || 0
}
which injects window as a dependency for testing the logic of the method. I am using SauceLabs in order to test the actual code on every browser to make sure the concept is valid. The thing is, the concept is valid: a manual test inside a browserstack real iPhone using DevTools to scroll by 20 shows that window.parent.window.scrollY is set to 20. Yet, doing this inside SauceLabs fails. I can see the thing running inside a simulated iPhone with the realtime video feature, and it looks normal, yet fails every single time.
What do I need to do to configure SauceLabs so the dang thing actually renders correctly to mirror how reality works?
Aucun commentaire:
Enregistrer un commentaire