enzyme - 如何检查组件是否已卸载?
enzyme - how can I check if the component is unmounted?
如标题所示,如何检查组件是否已卸载?
我尝试使用 component.length
检查它,但它总是有长度(不是零)。
有没有办法检查组件是否已卸载?
卸载的组件不应再成为 DOM 表示的一部分。
因此,您应该能够在未安装的组件选择器上使用酶的 exists
方法:
const component = wrapper.find('MyUnmountedComponent');
expect(component.exists()).toBe(false);
如标题所示,如何检查组件是否已卸载?
我尝试使用 component.length
检查它,但它总是有长度(不是零)。
有没有办法检查组件是否已卸载?
卸载的组件不应再成为 DOM 表示的一部分。
因此,您应该能够在未安装的组件选择器上使用酶的 exists
方法:
const component = wrapper.find('MyUnmountedComponent');
expect(component.exists()).toBe(false);