用jest快照测试带有ant-Motion的组件会发生问题
luojin315 opened this issue · 1 comments
luojin315 commented
组件代码:
<ScrollOverPack always={false}>
<QueueAnim type="right" duration="1000" className="imgBlindPlatoon" interval="200" style={{ ...style }}>
{
imgList.map(item => {
return <div className={`imgBox${item.id}`} key={item.id}>
{
item.img.map((img, index) => {
return <img src={img} alt="" key={index} />
})
}
</div>
})
}
</QueueAnim>
</ScrollOverPack>
测试代码:
it("render", () => {
const wrapper = mount(<ImgBlindPlatoon />);
let tree = wrapper.toJSON();
//渲染测试
expect(tree).toMatchSnapshot();
});
报错信息:
TypeError: _this.dom.getBoundingClientRect is not a function
| describe("PC:ImgBlindPlatoon", () => {
6 | it("render", () => {
> 7 | const wrapper = renderer.create(<ImgBlindPlatoon />);
| ^
8 | let tree = wrapper.toJSON();
at ScrollOverPack.ScrollElement._this.getParam (node_modules/_rc-scroll-anim@2.7.6@rc-scroll-anim/lib/ScrollElement.js:77:31)
at ScrollOverPack._this.scrollEventListener (node_modules/_rc-scroll-anim@2.7.6@rc-scroll-anim/lib/ScrollOverPack.js:74:13)
at ScrollOverPack.ScrollElement._this.addScrollEvent (node_modules/_rc-scroll-anim@2.7.6@rc-scroll-anim/lib/ScrollElement.js:119:15)
at ScrollOverPack.componentDidMount (node_modules/_rc-scroll-anim@2.7.6@rc-scroll-anim/lib/ScrollElement.js:145:12)