Skip to content

Commit c8ffa37

Browse files
committed
Translate Section 4.4
1 parent a9c3196 commit c8ffa37

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

readme-zh-TW.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,32 +1578,32 @@ it("Test addNewOrder, don't use such test names", () => {
15781578

15791579
<br/><br/>
15801580

1581-
## ⚪ ️4.4 Preventing test code issues with Test linters
1581+
## ⚪ ️4.4 使用 Test linter 來避免測試程式的問題
15821582

1583-
:white_check_mark: **Do:** A set of ESLint plugins were built specifically for inspecting the tests code patterns and discover issues. For example, [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) will warn when a test is written at the global level (not a son of a describe() statement) or when tests are [skipped](https://mochajs.org/#inclusive-tests) which might lead to a false belief that all tests are passing. Similarly, [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) can, for example, warn when a test has no assertions at all (not checking anything)
1583+
:white_check_mark: **建議:** 有一系列的 ESLint 外掛可以檢查測試程式的風格並發現問題。比如 [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) 會警告一個寫在 global 層的測試案例 (不是寫在 describe() 底下),或者當測試案例被 [skip](https://mochajs.org/#inclusive-tests) 時會發出警告,因為這可能會導致你誤會所有測試都通過了。類似的像,[eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) 可以在一個測試案例沒有任何斷言 (沒有檢查任何內容) 時給出警告。
15841584

15851585
<br/>
15861586

1587-
**Otherwise:** Seeing 90% code coverage and 100% green tests will make your face wear a big smile only until you realize that many tests aren’t asserting for anything and many test suites were just skipped. Hopefully, you didn’t deploy anything based on this false observation
1587+
**否則:** 當你滿足於 90% 的測試覆蓋率或 100% 的綠色報告時,卻發現很多測試都沒什麼斷言,或是很多測試直接被 skip 掉了。但願你沒有把這份程式佈署出去。
15881588

15891589
<br/>
1590-
<details><summary>✏ <b>Code Examples</b></summary>
1590+
<details><summary>✏ <b>程式範例</b></summary>
15911591

15921592
<br/>
15931593

1594-
### :thumbsdown: Anti-Pattern Example: A test case full of errors, luckily all are caught by Linters
1594+
### :thumbsdown: 反例:一個充滿錯誤的測試案例,還好都被 Linter 抓到了
15951595

15961596
```javascript
15971597
describe("Too short description", () => {
15981598
const userToken = userService.getDefaultToken() // *error:no-setup-in-describe, use hooks (sparingly) instead
1599-
it("Some description", () => {});//* error: valid-test-description. Must include the word "Should" + at least 5 words
1599+
it("Some description", () => {}); // *error: valid-test-description. Must include the word "Should" + at least 5 words
16001600
});
16011601

1602-
it.skip("Test name", () => {// *error:no-skipped-tests, error:error:no-global-tests. Put tests only under describe or suite
1603-
expect("somevalue"); // error:no-assert
1602+
it.skip("Test name", () => { // *error:no-skipped-tests, error:error:no-global-tests. Put tests only under describe or suite
1603+
expect("somevalue"); // *error:no-assert
16041604
});
16051605

1606-
it("Test name", () => {*//error:no-identical-title. Assign unique titles to tests
1606+
it("Test name", () => { // *error:no-identical-title. Assign unique titles to tests
16071607
});
16081608
```
16091609

0 commit comments

Comments
 (0)