關於describe和test執行順序的翻譯

MrZx發表於2018-07-09

++https://jestjs.io/docs/zh-Hans/setup-teardown++

## 原文 

Order of execution of describe and test blocks 

Jest executes all describe handlers in a test file before it executes any of the actual tests. This is another reason to do setup and teardown in before* and after* handlers rather in the describe blocks. Once the describe blocks are complete, by default Jest runs all the tests serially in the order they were encountered in the collection phase, waiting for each to finish and be tidied up before moving on. 

## 翻譯 

Jest 在處理一個指令碼的時候,會優先執行describe操作,然後再執行test操作,這是另一個原因,去處理建立和解除安裝再before\*和after\*模組中,而不是再describe模組中,一旦describe模組執行結束,預設情況下Jest會按照程式碼順序執行test操作,等所有的操作執行完畢程式才會繼續向下執行。

相關文章