【发布时间】:2020-10-02 15:28:45
【问题描述】:
在开玩笑地编写集成测试时,我想通过以下方式重现我在 mocha 中实现的相同行为:
mocha -r ts-node/register tests/integration/topLevelTest.test.ts 'tests/integration/**/*.test.ts'.
topLevelTest.test.ts:
let importantVariable;
describe("should do something with my variable", () => {
importantVariable = returnSomethingImportant();
it("should important variable exists", () => {
should.exist(importantVariable)
})
})
after(() => {
importantVariable.cleanUp()
})
行为很简单:首先 topLevelTest 执行 describe,然后其他测试套件自己执行,最后 after 在 topLevelTest 内执行。
在我尝试改写它以开玩笑时,我写了一些非常相似的东西。唯一的区别是我使用了 afterAll 而不是 after。结果是:首先执行 topLevelTest 描述,然后执行 afterAll,然后执行其他测试套件。是否可以让 afterAll 在其他测试套件之后运行?
【问题讨论】: