Dy4*_*Dy4 5 reactjs jestjs material-ui react-testing-library
是否可以在特定的 Material UI 图标中作为 ArrowLeft / ArrowRight 而不是 .MuiSvgIcon-root 进行测试?
应用组件:
return {open ? <ArrowLeft/> :<ArrowRight/>}
Run Code Online (Sandbox Code Playgroud)
RTL 测试:下面的测试正在通过,但它不会检查特定的 ArrowLeft 或 ArrowRight 图标。
describes("MockTest",()=>{
it("renders Left arrow",()=>{
const {container} = renders(<App open={true}/>);
expect(container.querySelector(".MuiSvgIcon-root").toBeTruthy();
});
it("renders Right arrow",()=>{
const {container} = renders(<App open={false}/>);
expect(container.querySelector(".MuiSvgIcon-root").toBeTruthy();
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
399 次 |
| 最近记录: |