Mocha beforeEach vs before execution

后端 未结 4 1217
死守一世寂寞
死守一世寂寞 2020-12-24 04:42

I ran into a problem recently that I can\'t explain. I have alot of code in these tests so I\'m going to do my best to capture the idea here

I have tests that look li

4条回答
  •  不思量自难忘°
    2020-12-24 05:34

    The reason of confusion is lies in the documentation of mocha. You can find in mocha:

    Tests can appear before, after, or interspersed with your hooks. Hooks will run in the order they are defined, as appropriate; all before() hooks run (once), then any beforeEach() hooks, tests, any afterEach() hooks, and finally after() hooks (once).

    Discussed hooks before and beforeEach are executed right before all or each it respectively - there are no way to execute it before describe section.

    Here you can find answer of the #1 contributor to the mocha's master branch to the idea add something like beforeDescribe hook.

    I think you should look at the --delay mocha option.

提交回复
热议问题