1

In our react-native application, we are developing custom style component for our component.

The style component contains StyleSheet example:

export default StyleSheet.create({
  container: {
    flexGrow: 1,
    justifyContent: "center",
    alignItems: "center",
    borderTopWidth: 1,
  },
});

As this component is imported in our component and when we do unit testing of our component it goes 30 times in it and shows that if and else part were not run which leads to less coverage(style component is imported in the component)

So I have included a screenshot which explains the issue. Note that rest whole component is tested and fully covered. So the coverage which is left is for style component.

octobus
  • 1,246
  • 1
  • 14
  • 20

1 Answers1

0

It should return an object that looks like this

style={
    Object {
      flexGrow: 1,
      justifyContent: "center",
      alignItems: "center",
      borderTopWidth: 1,
    }
}

You can compare it with it and see if it is worth it or not

You can understand the direction of my thinking through this link

Yoel
  • 7,555
  • 6
  • 27
  • 59
  • 1
    I tried this but it didn't solved the problem. Instead now it goes 60 times in it as compared to 30 times. Coverage is still the same – Kushal Bansal Dec 13 '19 at 06:31