React Native

React Native Testing

Jest, React Native Testing Library, testing hooks, testing navigation, async testing, mocking, E2E with Detox

20 câu hỏi phỏng vấn·
Mid-Level
1

What is the main role of Jest in a React Native project?

Câu trả lời

Jest is the default JavaScript testing framework bundled with React Native. It handles test execution, assertions, mocking and code coverage. Unlike other tools that specialize in a particular aspect, Jest provides a complete solution natively integrated into React Native.

2

What is the main function of React Native Testing Library (RNTL)?

Câu trả lời

React Native Testing Library encourages tests focused on user behavior rather than implementation details. It provides utilities to query components as a user would (by text, accessible role, placeholder), making tests more resilient to internal refactoring.

3

Which RNTL query method should be preferred to select a button with the text 'Submit'?

Câu trả lời

getByText is the recommended method because it selects elements as a user would, by looking for visible text. This approach makes tests more intuitive and resilient. getByTestId requires adding testID attributes and does not reflect actual user behavior.

4

What is the difference between getBy and queryBy in RNTL?

5

How to configure Jest to skip transformations for certain node_modules in React Native?

+17 câu hỏi phỏng vấn

Nắm vững React Native cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí