I've been thinking of starting a new project with react native and I want to use the test-driven development. Is it going to be an efficient approach or just write the test later? Let me know your thoughts. Thanks! π»
You can't go wrong writing unit and feature tests. Especially if you work with any external API - tests would help ensure it's working properly (allowing you to debug app-specific issues vs API).
I think that a lot of the issues you'd face with React Native development are hardware based, so E2E testing would be more important than unit testing. Though currently, I'm pretty sure there isn't a testing library that can mock/assert against the Android and iOS operating systems (like Chromium or Selenium for web browsers). Meaning automated or programmatic E2E testing isn't possible on mobile, requiring manual testing anyway.
TDD means writing tests first, so write breaking tests first.
This will be slower than usual development but it'll help you in the long run.
Your code will be better as well as you'll be forced to write testable code so you'll end up with overall better code.
If you've never done testing before there's a workshop video by kentcdodds on YouTube, that video helped me a lot π
I've read all the responses for your question, I'm agree with all of them, but only if you are a experimented react-native developer. In case you are learning react-native, I'm afraid that you need to learn TDD in other scenarios, and then come back to react-native.
Just found this today, an end-to-end testing framework for React Native. It's in early development, but looks nifty:
Shahjada Talukdar
Senior Software Engineer @eBay
It's always better to write test from the beginning. When the app will be bigger, it would be hard to write test newly. and I think this is one of the reasons a lot of teams dont wanna start writing tests later. For react tests, JEST is a good option and if you wanna do E2E, you can try CYPRESS too
jestjs.io
cypress.io