Skip to content

Commit c68595a

Browse files
feat/translate docs/testing.md
1 parent fc52d95 commit c68595a

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

content/docs/testing.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,43 @@ redirect_from:
77
next: testing-recipes.html
88
---
99

10-
You can test React components similar to testing other JavaScript code.
10+
Bạn có thể kiểm tra các React component tương tự như việc kiểm tra những code Javascript khác.
1111

12-
There are a few ways to test React components. Broadly, they divide into two categories:
12+
Có một số cách để testing các React component. Nói chung, chúng được chia thành 2 thành phần:
1313

14-
* **Rendering component trees** in a simplified test environment and asserting on their output.
15-
* **Running a complete app** in a realistic browser environment (also known as “end-to-end” tests).
14+
* **Rendering component trees** trong một môi trường test được đơn giản hóa và khẳng định trên kết quả đầu ra của chúng.
15+
* **Running a complete app** trong một môi trường trình duyệt thực tế (hay còn được gọi là “end-to-end” tests).
1616

17-
This documentation section focuses on testing strategies for the first case. While full end-to-end tests can be very useful to prevent regressions to important workflows, such tests are not concerned with React components in particular, and are out of the scope of this section.
17+
Phần tài liệu này tập trung vào chiến lược testing cho trường hợp đầu tiên. Mặc dù các end-to-end tests đầy đủ có thể rất hữu ích để ngăn ngừa sự hồi quy
18+
đối với những luồng làm việc quan trọng, nhưng các tests đó không liên quan đến các React component nói chung, và nằm ngoài phạm vi của phần này.
1819

19-
### Tradeoffs {#tradeoffs}
20+
### Những đánh đổi {#tradeoffs}
2021

2122

22-
When choosing testing tools, it is worth considering a few tradeoffs:
23+
Khi lựa chọn những công cụ kiểm tra, cần cân nhắc một số đánh đổi sau:
2324

24-
* **Iteration speed vs Realistic environment:** Some tools offer a very quick feedback loop between making a change and seeing the result, but don't model the browser behavior precisely. Other tools might use a real browser environment, but reduce the iteration speed and are flakier on a continuous integration server.
25-
* **How much to mock:** With components, the distinction between a "unit" and "integration" test can be blurry. If you're testing a form, should its test also test the buttons inside of it? Or should a button component have its own test suite? Should refactoring a button ever break the form test?
25+
* **Tốc độ lặp lại so với với môi trường thực tế:** Một số công cụ cung cấp một vòng lặp phản hồi rất nhanh giữa việc thực hiện một thay đổi và xem xét kết quả,
26+
nhưng không mô hình hóa chính xác hành vi của trình duyệt. Các công cụ khác có thể sử dụng một môi trường trình duyệt thực tế, nhưng lại giảm tốc độ lặp lại và dễ
27+
bị phá vỡ hơn trên một máy chủ tích hợp liên tục.
28+
* **Mô phỏng bao nhiêu:** Với các components, sự khác biệt giữa một "đơn vị" test và "tập hợp" test có thể bị lu mờ. Nếu bạn đang thử nghiệm trên một
29+
form, liệu việc kiểm tra nó có nên kiểm tra luôn các button bên trong nó hay không? Hoặc một button component có nên có cho nó một bộ test riêng hay không? Liệu việc
30+
tái cấu trúc một button có làm phá vỡ form test?
2631

27-
Different answers may work for different teams and products.
32+
Những câu trả lời khác nhau có thể phù hợp cho những team và những sản phẩm khác nhau.
2833

29-
### Recommended Tools {#tools}
34+
### Những công cụ được đề xuất {#tools}
3035

31-
**[Jest](https://facebook.github.io/jest/)** is a JavaScript test runner that lets you access the DOM via [`jsdom`](/docs/testing-environments.html#mocking-a-rendering-surface). While jsdom is only an approximation of how the browser works, it is often good enough for testing React components. Jest provides a great iteration speed combined with powerful features like mocking [modules](/docs/testing-environments.html#mocking-modules) and [timers](/docs/testing-environments.html#mocking-timers) so you can have more control over how the code executes.
36+
**[Jest](https://facebook.github.io/jest/)** là một trình chạy thử nghiệm cho phép bạn truy cập vào DOM thông qua [`jsdom`](/docs/testing-environments.html#mocking-a-rendering-surface). Trong đó jsdom chỉ là một ước tính về cách mà trình duyệt hoạt động, nó thường đủ tốt để kiểm tra React components. Jest cung cấp
37+
một tốc độ lặp lại tuyệt vời kết hợp với các tính năng mạnh mẽ như [modules](/docs/testing-environments.html#mocking-modules) mô phỏng (mocking) và một [timers](/docs/testing-environments.html#mocking-timers) cho phép bạn có thể kiểm soát nhiều hơn cách mà một mã code được thực thi.
3238

33-
**[React Testing Library](https://testing-library.com/react)** is a set of helpers that let you test React components without relying on their implementation details. This approach makes refactoring a breeze and also nudges you towards best practices for accessibility. Although it doesn't provide a way to "shallowly" render a component without its children, a test runner like Jest lets you do this by [mocking](/docs/testing-recipes.html#mocking-modules).
39+
**[React Testing Library](https://testing-library.com/react)** là tập hợp các trình trợ giúp cho phép bạn test React components mà không cần dựa vào các chi tiết triển
40+
khai của họ. Cách tiếp cận này giúp cho việc tái cấu trúc trở nên một cách dễ dàng và cũng thúc đẩy bạn hướng tới các phương pháp tiếp cận hay nhất về khả năng
41+
truy cập. Mặc dù nó không cung câp một cách "shallowly" (nông cạn - đối lập với deep) đối với render một component mà không có thành phần con của nó, một test thử nghiệm
42+
như Jest cho phép bạn làm điều này thông qua [mocking](/docs/testing-recipes.html#mocking-modules)(mô phỏng).
3443

35-
### Learn More {#learn-more}
44+
### Tìm hiểu thêm {#learn-more}
3645

37-
This section is divided in two pages:
46+
Phần này được chia làm hai trang:
3847

39-
- [Recipes](/docs/testing-recipes.html): Common patterns when writing tests for React components.
40-
- [Environments](/docs/testing-environments.html): What to consider when setting up a testing environment for React components.
48+
- [Recipes](/docs/testing-recipes.html): Các patterns thường gặp khi viết các tests cho React components.
49+
- [Environments](/docs/testing-environments.html): Những điều cần cân nhắc khi thiết lập môi trường testing cho React components.

0 commit comments

Comments
 (0)