How to print the contents of enzyme's shallow wrapper

删除回忆录丶 提交于 2020-06-10 07:57:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!