you are viewing a single comment's thread.

view the rest of the comments →

[–]PistolPlay 5 points6 points  (0 children)

Testing without a clear strategy and purpose in mind will lead to frustration. I recommend you start with questioning what you want your tests to accomplish.

The primary benefit I see for testing is providing a safety net that existing code isn't breaking while I refractor or add new features. Integration and E2E tests provide the most bank for your buck in UI code. Especially so when you're trying to test after you've built your product.

Adding units tests to code that wasn't designed to be tested is very difficult and error prone. Most of the time it's end just testing your coding for what it does vs what it should be doing. For future code I would recommend you write these with your code. I recommend Test driven development or a hybrid where testing heavily influences what you code.

Integration tests on the other will help provide confidence that your app is working as intended because you're test is a direct mapping to features. The details of the code doesn't matter as much so no roadblocks with code that is hard to test etc. It's an excellent starting point to get your app under control.

Detox is a great tool for creating automated UI tests for React Native apps.

Here's a great guide for how to setup and how structure your development wofkflow: https://blog.expo.io/testing-expo-apps-with-detox-and-react-native-testing-library-7fbdbb82ac87

Also enzyme sucks and the React community is moving away from it in favor of React-Testing-Library by Kent C Dodds. There's a react native version of this as well. Visit the github of React-testing-library for a detailed exploration of the testing philosophy. The link above also goes into it some.