The Art of Humble Views: Testing React Native Apps the Smart Way - Mo Khazali, TestJS Summit 2023

Learn how to write clean, testable React Native apps using the humble object model, MVP model, and presenter layer. Achieve 100% test coverage and fall into the pit of success with well-designed systems.

Key takeaways
  • Encourage clean code and architecture by creating well-designed systems that make it easier to test and scale applications.
  • Use the humble object model to isolate important business components, making them easier to test and more scalable.
  • Separate infrastructure code, UI state, and logic into distinct modules to improve testability and code organization.
  • Utilize a one hook per screen rule to limit the complexity of components and make testing more manageable.
  • Test the core business logic rather than the UI to reduce the amount of code that needs to be tested and improve the effectiveness of tests.
  • Create passive views that are easy to test by separating UI state and logic from the view itself.
  • Use a presenter layer to contain UI state and logic, making it easier to test the critical components of an app.
  • Aim for 100% test coverage to ensure a high-quality codebase and reduce the risk of bugs.
  • Encourage developers to fall into the pit of success by creating well-designed systems that make it easy to write effective tests.
  • Use a combination of the humble object model, MVP model, and presenter layer to create easily testable and scalable React and React Native applications.