Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print the contents of enzyme's shallow wrapper

I have the following :

import {shallow} from "enzyme" 

const wrapper = shallow(<SampleComponent/>);

how do I see the contents of wrapper?

like image 889
Samjunior Avatar asked Apr 26 '18 19:04

Samjunior


2 Answers

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());
like image 112
Guilherme Lemmi Avatar answered Oct 22 '22 13:10

Guilherme Lemmi


import {shallow} from "enzyme";
const wrapper = shallow(<SampleComponent/>);
console.log(wrapper.html());
like image 22
sam Avatar answered Oct 22 '22 13:10

sam