mocha-allure-reporter
Advanced tools
Comparing version 1.3.1 to 1.3.2
38
index.js
@@ -20,17 +20,27 @@ "use strict"; | ||
runner.on("suite", function (suite) { | ||
function invokeHanlder(handler) { | ||
return function() { | ||
try { | ||
return handler.apply(this, arguments); | ||
} catch(error) { | ||
console.error("Internal error in Allure:", error); // eslint-disable-line no-console | ||
} | ||
}; | ||
} | ||
runner.on("suite", invokeHanlder(function (suite) { | ||
allureReporter.startSuite(suite.fullTitle()); | ||
}); | ||
})); | ||
runner.on("suite end", function () { | ||
runner.on("suite end", invokeHanlder(function () { | ||
allureReporter.endSuite(); | ||
}); | ||
})); | ||
runner.on("test", function(test) { | ||
runner.on("test", invokeHanlder(function(test) { | ||
if (typeof test.currentRetry !== "function" || !test.currentRetry()) { | ||
allureReporter.startCase(test.title); | ||
} | ||
}); | ||
})); | ||
runner.on("pending", function(test) { | ||
runner.on("pending", invokeHanlder(function(test) { | ||
var currentTest = allureReporter.getCurrentTest(); | ||
@@ -42,9 +52,9 @@ if(currentTest && currentTest.name === test.title) { | ||
} | ||
}); | ||
})); | ||
runner.on("pass", function() { | ||
runner.on("pass", invokeHanlder(function() { | ||
allureReporter.endCase("passed"); | ||
}); | ||
})); | ||
runner.on("fail", function(test, err) { | ||
runner.on("fail", invokeHanlder(function(test, err) { | ||
if(!allureReporter.getCurrentTest()) { | ||
@@ -58,11 +68,11 @@ allureReporter.startCase(test.title); | ||
allureReporter.endCase(status, err); | ||
}); | ||
})); | ||
runner.on("hook end", function(hook) { | ||
runner.on("hook end", invokeHanlder(function(hook) { | ||
if(hook.title.indexOf('"after each" hook') === 0) { | ||
allureReporter.endCase("passed"); | ||
} | ||
}); | ||
})); | ||
} | ||
module.exports = AllureReporter; |
{ | ||
"name": "mocha-allure-reporter", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Mocha reporter for Allure framework", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -133,2 +133,17 @@ var path = require("path"); | ||
}); | ||
it("should report internal errors", function(done) { | ||
sinon.stub(console, "error"); | ||
var mocha = new Mocha({ | ||
reporter: reporter | ||
}); | ||
allureMock.endSuite.onCall(1).throws(); | ||
mocha.addFile(path.join(__dirname, "../fixtures/retries.spec.js")); | ||
mocha.run(function() { | ||
expect(console.error).callCount(1); | ||
expect(console.error).calledWith("Internal error in Allure:", sinon.match.instanceOf(Error)); | ||
console.error.restore(); | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312
25094
17