1
votes

Using React Native, jest, and enzyme, I'm not able to even inspect the value of a shallow rendered component, let alone run a test assertion on it.

Enzyme and jest are working fine for other test files.

There is no log output in my console of any errors occurring.

import React from 'react';
import { shallow } from 'enzyme';
import { SomeComponent } from '../SomeComponent';

describe('SomeComponent', () => {
  it('renders', () => {
    const props = { name: 'hey' }
    const shallowWrap = shallow(<SomeComponent {...props} />);
    console.log(shallowWrap) // this wont even log
    expect(shallowWrap).toMatchSnapshot();
  });
});
1

1 Answers

-1
votes
try {
  const shallowWrap = shallow(<SomeComponent {...props} />);
} catch (e) {
  console.log(e)
}

Wrapping a try/catch around the shallowing of my component and logging the error showed I had an error being thrown in SomeComponent's render function.

Fixed the cause of that error and works perfect now.