Reactjs 如何用酶测试一个元素在另一个元素之后?
所以我有一个div需要测试。我需要测试ul是否紧跟在div之后。这在Enzme中可能吗?我在用酶和笑话 这是正在讨论的divReactjs 如何用酶测试一个元素在另一个元素之后?,reactjs,jestjs,enzyme,Reactjs,Jestjs,Enzyme,所以我有一个div需要测试。我需要测试ul是否紧跟在div之后。这在Enzme中可能吗?我在用酶和笑话 这是正在讨论的div it('nav at bottom when bottom theme is present', () => { const wrapper = shallow( <div className="tabs tab-icon-dark-bkg-bottom"> <div
it('nav at bottom when bottom theme is present', () => {
const wrapper = shallow(
<div className="tabs tab-icon-dark-bkg-bottom">
<div className="tab-content transition">
</div>
<ul className="scroll nav nav-tabs">
</ul>
</div>
);
//
expect(wrapper.????).toBe(true);
});
it('nav在底部,当底部主题存在时,()=>{
常数包装=浅(
);
//
期望(包装)为(真);
});
支持CSS选择器,如
用于选择紧跟在第一个指定图元之后(而不是在其内部)放置的图元
使用'div+ul'
调用.find
,查找紧跟在div
之后的所有ul
元素:
it('nav at bottom when bottom theme is present', () => {
const wrapper = shallow(
<div className="tabs tab-icon-dark-bkg-bottom">
<div className="tab-content transition">
</div>
<ul className="scroll nav nav-tabs">
</ul>
</div>
);
expect(wrapper.find('div + ul').length).toBe(1); // SUCCESS
});
it('nav在底部,当底部主题存在时,()=>{
常数包装=浅(
);
expect(wrapper.find('div+ul').length).toBe(1);//成功
});
支持CSS选择器,如
用于选择紧跟在第一个指定图元之后(而不是在其内部)放置的图元
使用'div+ul'
调用.find
,查找紧跟在div
之后的所有ul
元素:
it('nav at bottom when bottom theme is present', () => {
const wrapper = shallow(
<div className="tabs tab-icon-dark-bkg-bottom">
<div className="tab-content transition">
</div>
<ul className="scroll nav nav-tabs">
</ul>
</div>
);
expect(wrapper.find('div + ul').length).toBe(1); // SUCCESS
});
it('nav在底部,当底部主题存在时,()=>{
常数包装=浅(
);
expect(wrapper.find('div+ul').length).toBe(1);//成功
});