不pipetesting失败,摩卡都会运行吗?

就像标题所说的那样。 即使testing失败,在Mocha工作before / after / before / after afterEach挂钩吗?

是的,即使testing失败,他们仍然运行。 但是,如果您使用保释选项运行Mocha,则拆卸挂钩将不会运行。

只是在这里做了一个现有的testing套件快速检查。
代码:

 setup(function() { console.log("1"); }); teardown(function() { console.log("2"); }); 

处决:

 D:\Dev\JS\toposort>mocha Toposort ◦ should sort correctly: 1 √ should sort correctly 2 ◦ should find cyclic dependencies: 1 1) should find cyclic dependencies 2 ◦ #2 - should add the item if an empty array of dependencies is passed: 1 √ #2 - should add the item if an empty array of dependencies is passed 2 2 passing (15 ms) 1 failing 1) Toposort should find cyclic dependencies: AssertionError: expected [Function] to not throw 'Error' but [Error: Cyclic dependency found. '3' is dependent of itself .] was thrown D:\Dev\JS\toposort>mocha --bail Toposort ◦ should sort correctly: 1 √ should sort correctly 2 ◦ should find cyclic dependencies: 1 1) should find cyclic dependencies 1 passing (14 ms) 1 failing 1) Toposort should find cyclic dependencies: AssertionError: expected [Function] to not throw 'Error' but [Error: Cyclic dependency found. '3' is dependent of itself .] was thrown