From c26d04884540d2a7dd3288b7f7f3625d4430430b Mon Sep 17 00:00:00 2001 From: just-boris Date: Thu, 3 Sep 2015 19:08:59 +0300 Subject: [PATCH] include after each hooks into report --- index.js | 6 ++++++ package.json | 2 +- test/fixtures/hooks.spec.js | 21 +++++++++++++++++++++ test/fixtures/simple.spec.js | 4 +--- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/hooks.spec.js 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() {