我需要测试一个快照,该快照也具有一个称为aria-labelledby
的属性,并且由无法修改或模拟的某些函数创建。每次运行测试时,该属性都会获得一个新值,我也不在乎它是什么。
所以,有没有办法提及aria-labelledby
不被检查?
Test
it('My Test', () => {
let wrapper: ReactWrapper;
wrapper = mount(<App />);
expect(wrapper.find(App)).toMatchSnapshot();
});
快照
.....
}
unmountOnExit={false}
>
<div
- aria-labelledby="pr_id_1_label" <===== SNAPSHOT VALUE
+ aria-labelledby="pr_id_2_label" <===== NEW VALUE WHICH CAUSES THE TEST FAIL!!!!
className="p-dialog p-component"
.....
作为使用enzyme-to-json
的一种解决方法,我们may specify .map()
option能够过滤道具:
.map()