I am using Jest with React-Native and I came across a problem.
A tiny piece of code in the App.js component that causes a 50:50 fork to span:
const storeMiddleware = __DEV__ ?
applyMiddleware(
thunkMiddleware,
loggerMiddleware
) :
applyMiddleware(
thunkMiddleware
);
Test case itself:
import 'react-native';
import React from 'react';
import App from '../App.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
describe('App', () => {
it('should render correctly', () => {
const tree = renderer.create(
<App />
).toJSON();
expect(tree).toMatchSnapshot();
});
// TODO: test if app renders correctly when __DEV__ is false
});
How do I change my test to get 100% coverage
source
share