Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HTML reporter #724 #801

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions lib/reporters/Html.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
define([
'require',
'../util',
], function (require, util) {

'../util'
], function (
require,

util
) {
var location = window.location;

function getFullName(test) {
var name = test.name;
while (test.parent && test.parent.name) {
test = test.parent;
name = test.name + ' - ' + name;
}
return name;
}

function createLinkNode(test) {
var text = test.name;
var a = document.createElement('a');
var search = location.search;

if (search) {
search = search.slice(1).split("&").filter(function (el) {
return !el.startsWith("grep");
}).join("&");
}

search = "?" + search + "&grep=/" + getFullName(test) + "/";
a.href = location.origin + location.pathname + search;
a.appendChild(document.createTextNode(text));
return a;
}

function pad(value, size) {
var padded = String(value);

Expand Down Expand Up @@ -338,7 +371,7 @@ define([
suiteCount++;

cellNode.className = 'title';
cellNode.appendChild(document.createTextNode(suite.name));
cellNode.appendChild(createLinkNode(suite));
rowNode.className = 'suite';
rowNode.appendChild(cellNode);
reportNode.appendChild(rowNode);
Expand Down Expand Up @@ -393,7 +426,7 @@ define([
var numSkippedTests = suite.numSkippedTests;
var numPassedTests = numTests - numFailedTests - numSkippedTests;

// Mark a suite as failed if any of its child tests failed, and
// Mark a suite as failed if any of its child tests failed, and
addClass(rowNode, numFailedTests > 0 ? 'failed' : 'passed');

// Only suites with failed tests will be initially expanded
Expand Down Expand Up @@ -471,7 +504,7 @@ define([
cellNode.className += ' indent' + indentLevel;
}

cellNode.appendChild(document.createTextNode(test.name));
cellNode.appendChild(createLinkNode(test));
rowNode.appendChild(cellNode);

cellNode = document.createElement('td');
Expand Down