【发布时间】:2021-09-23 14:54:35
【问题描述】:
我想测试类名“.button_next 重音”是否存在。
<Button
className={`${this.props.nextAccent && "accent"} button_next`}
text={this.props.textNext}
icon={"iconnext"}
onClick={this.props.nextButtonClicked}
/>
我的测试
Then(/^Next button contains accent/, function () {
const wrapper = enzyme.mount(App);
let nextButton = wrapper.find('.button_next').exists(); //here i want to check both
.button_next and accent
return (expect(nextButton).to.be.equal(true));
//gave this a try
// FAILED: let nextButton = wrapper.find('.button_next .accent').exists();
// FAILED: let nextButton = wrapper.find('button_next accent').exists();
// FAILED: let nextButton = wrapper.find('.button_next accent').exists();
});
【问题讨论】:
-
我想你可以试试
enzyme.mount(<App />);。此enzymejs.github.io/enzyme 的文档
标签: javascript reactjs jestjs enzyme classname