React Native 支持多个层级的测试 — unit tests(逻辑)、component tests(使用 React Native Testing Library)和 end-to-end tests(使用 Detox)。良好的测试策略可以提高可靠性和信心。
Unit 和 component 测试(Jest + Testing Library)
JEST → the standard JS test runner (unit tests for logic, functions, hooks)
REACT NATIVE TESTING LIBRARY → test components by rendering and interacting with them
(the way a user would) — query elements, fire events, assert on output
{ render, fireEvent, screen } ;
(, {
();
fireEvent.(screen.());
(screen.()).();
});
