Jest + Enzyme + React Native: How to test content of tag?
Clash Royale CLAN TAG #URR8PPP Jest + Enzyme + React Native: How to test content of <Text /> tag? I want to unit test with Jest and Enzyme if my <Text /> tag correctly receives props.header as text. <Text /> props.header Usually I was able to test the content of the <Text /> tag like this: <Text /> it("should render a label", () => { expect(wrapper.find(Text).contains("submit")).toBe(true); }); But as soon as I pass an object this is no longer possible. Let me show you: const createTestProps = props => ({ header: SOME_CONSTANT, ...props }); ... let wrapper; let props; beforeEach(() => { props = createTestProps(); wrapper = shallow(<MyList {...props} loaded={false} />); }); it("should render a header", () => { expect(wrapper.find(Text).contains(props.header)).toBe(true); }); This fails with the following error message: ● MyList › rendering › still loading › should render a head...