diff --git a/index.js b/index.js index fdf2304..45b5572 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,12 @@ function AllureReporter(runner, opts) { } allureReporter.endCase(status, err); }); + + runner.on("hook end", function(hook) { + if(hook.title.indexOf('"after each" hook') === 0) { + allureReporter.endCase("passed"); + } + }); } module.exports = AllureReporter; diff --git a/package.json b/package.json index ebafaa0..7388636 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "sinon-chai": "^2.7.0" }, "dependencies": { - "allure-js-commons": "1.0.2", + "allure-js-commons": "1.0.3", "mocha": "^2.2.4" } } diff --git a/test/fixtures/hooks.spec.js b/test/fixtures/hooks.spec.js new file mode 100644 index 0000000..1b54561 --- /dev/null +++ b/test/fixtures/hooks.spec.js @@ -0,0 +1,21 @@ +describe("Hooks tests", function() { + describe("broken teardown", function() { + beforeEach(function() {}); + it("a test", function() {}); + it("a second test", function() {}); + + afterEach("broken afterEach", function() { + throw new Error("I am broken"); + }); + }); + + describe("broken setup", function() { + beforeEach(function() { + throw new Error("You shall not pass"); + }); + + it("a test", function() {}); + }) + + afterEach("passing afterEach", function() {}); +}); diff --git a/test/fixtures/simple.spec.js b/test/fixtures/simple.spec.js index 4fab48f..fef64ac 100644 --- a/test/fixtures/simple.spec.js +++ b/test/fixtures/simple.spec.js @@ -11,9 +11,7 @@ describe("A mocha suite", function() { }), firstStep = allure.createStep("simple step", function() {}); - beforeEach(function() { - - }); + beforeEach(function() {}); describe("passing", function() { it("simple test", function() {