Skip to content

Commit

Permalink
Fix error reporting
Browse files Browse the repository at this point in the history
- Error list is not reset by reference anymore
- All errors are include in the report, not only the first one
  • Loading branch information
Vasilii Besschetnov authored and Vasilii-Besschetnov committed Mar 18, 2019
1 parent 2ac9cf5 commit d72b6a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions lib/runner/reporters/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ module.exports = new (function() {
function adaptErrMessages(module) {
Object.keys(module.completed).forEach(function(item) {
var testcase = module.completed[item];
var errmessages = testcase.errmessages;
if (errmessages.length) {
var stackParts = errmessages[0].split('\n');
stackParts.shift();
testcase.errorStackTrace = Utils.stackTraceFilter(stackParts);
var errorMessages = testcase.errmessages;
for (var i = 0; i < errorMessages.length; i++) {
if (errorMessages[i].stackTrace) {
errorMessages[i] = Utils.stackTraceFilter(errorMessages[i].split('\n'));
}
}
});
}
Expand Down
10 changes: 6 additions & 4 deletions lib/runner/reporters/junit.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
tests="<%= module.tests %>" time="<%= module.time %>" timestamp="<%= module.timestamp %>">
<% for (var item in module.completed) {
var testcase = module.completed[item];
var assertions = testcase.assertions %>
var assertions = testcase.assertions;
var errorMessages = testcase.errmessages || [];
%>
<testcase name="<%= item %>" classname="<%= className %>" time="<%= testcase.time %>" assertions="<%= assertions.length %>"><%
for (var i = 0; i < assertions.length; i++) { %><% if (assertions[i].failure) { %> <failure message="<%= assertions[i].message %>"><%= assertions[i].stackTrace %></failure><% } %>
<% if (assertions[i].screenshots && assertions[i].screenshots.length > 0) { %><system-out><% for (var j = 0; j < assertions[i].screenshots.length; j++) { %>[[ATTACHMENT|<%= assertions[i].screenshots[j] %>]]<% } %></system-out><% } %>
<% }
if (testcase.failed > 0 && testcase.stackTrace) {
%><failure message="<%= testcase.message %>"><%= testcase.stackTrace %></failure><% }
if (testcase.errors > 0 && testcase.errorStackTrace) {
%>
<error message="Error executing test code"><%= testcase.errorStackTrace %></error><% } %>
for (var i = 0; i < errorMessages.length; i++) { %>
<error message="Error executing test code"><%= errorMessages[i] %></error>
<% } %>
</testcase><% if (systemerr != '') {%>
<system-err>
<%= systemerr %>
Expand Down
2 changes: 1 addition & 1 deletion lib/runner/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Runner.prototype.runTestModule = function(modulePath, fullPaths) {
timeMs : time,
time : (time/1000).toPrecision(4),
stackTrace : results.stackTrace,
errmessages: errors
errmessages: errors.slice()
};

if (Array.isArray(errors) && errors.length) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nightwatch",
"description": "A node.js bindings implementation for selenium 2.0/webdriver",
"version": "0.9.15.1",
"version": "0.9.15.2",
"author": {
"name": "Andrei Rusu",
"email": "[email protected]"
Expand Down

0 comments on commit d72b6a4

Please sign in to comment.