关于describe和test执行顺序的翻译

1,583 阅读1分钟

++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操作,等所有的操作执行完毕程序才会继续向下执行。