问题
I have the following :
import {shallow} from "enzyme"
const wrapper = shallow(<SampleComponent/>);
how do I see the contents of wrapper?
回答1:
You can use wrapper.debug() to get a string representing the wrapper element, like in:
import {shallow} from "enzyme";
const wrapper = shallow(<SampleComponent/>);
console.log(wrapper.debug());
回答2:
import {shallow} from "enzyme";
const wrapper = shallow(<SampleComponent/>);
console.log(wrapper.html());
来源:https://stackoverflow.com/questions/50050675/how-to-print-the-contents-of-enzymes-shallow-wrapper