Skip to content

Commit

Permalink
Update table with assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Palina Lushchynskaya committed Nov 8, 2018
1 parent 2c9212b commit ceeff4c
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const gulp = require('gulp');
const babel = require('gulp-babel');
const mocha = require('gulp-mocha');
const del = require('del');
var eslint = require('gulp-eslint');
const eslint = require('gulp-eslint');

function clean(cb) {
return del(['lib', cb]);
}

function lint () {
function lint() {
return gulp
.src([
'src/**/*.js',
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<html lang="en"><head><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"></head><body><div class="container"><h1 class="text-primary">TestCafe Test Summary</h1><br><div class="client-logo" style="padding:15px"></div><div class="bg-primary" style="padding:15px"><h3>Summary</h3><br><p class="lead">Start Time: 1/1/1970 0:0:0</p><p class="lead">Browsers: Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</p><p class="lead">Duration: 0s</p><p class="lead">Tests Failed: 2 out of 6</p><p class="lead">Tests Skipped: 0</p></div><br><table class="table "><tr><th>Test ID</th><th>Fixture</th><th>Test Name</th><th>Browser</th><th>Duration</th><th>Result</th><th>Screenshot</th></tr> <tr class="success">
<td>test-1</td>
<td>First fixture</td>
<td>First test in first fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>1m 14s</td>
<td>passed</td>
<td>no screenshot</td>
</tr>
<tr class="danger">
<td> <a href="#test-2">test-2</a>
</td>
<td>First fixture</td>
<td>Second test in first fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>1m 14s</td>
<td>failed</td>
<td> <a href="test/First fixture/Second test in first fixture/test-2.png"> <img src="test/First fixture/Second test in first fixture/thumbnails/test-2.png" img>
</a>
</td>
</tr>
<tr class="success">
<td>test-3</td>
<td>First fixture</td>
<td>Third test in first fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>1m 14s</td>
<td>passed</td>
<td>no screenshot</td>
</tr>
<tr class="success">
<td>test-4</td>
<td>Second fixture</td>
<td>First test in second fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>1m 14s</td>
<td>passed</td>
<td>no screenshot</td>
</tr>
<tr class="success">
<td>test-5</td>
<td>Second fixture</td>
<td>Second test in second fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>1m 14s</td>
<td>passed</td>
<td>no screenshot</td>
</tr>
<tr class="success">
<td>test-6</td>
<td>Second fixture</td>
<td>Third test in second fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>0s</td>
<td>passed</td>
<td>no screenshot</td>
</tr>
<tr class="danger">
<td> <a href="#test-7">test-7</a>
</td>
<td>Third fixture</td>
<td>First test in third fixture</td>
<td>Chrome 41.0.2227 / Mac OS X 10.10.1, Firefox 47 / Mac OS X 10.10.1</td>
<td>1m 14s</td>
<td>failed</td>
<td> <a href="nul/Third fixture/First test in third fixture/test-7.png"> <img src="nul/Third fixture/First test in third fixture/thumbnails/test-7.png" img>
</a>
</td>
</tr>
</table><br><br><h3>Error Details</h3><br> <h4 id="test-2">First fixture - Second test in first fixture</h4>
<pre>undefinedError on page "http://example.org":

Some error

Browser: Chrome 41.0.2227 / Mac OS X 10.10.1
Screenshot: screenshots/1445437598847/errors </pre> <pre>undefinedThe specified selector does not match any element in the DOM tree.

Browser: Firefox 47 / Mac OS X 10.10.1 </pre> <h4 id="test-7">Third fixture - First test in third fixture</h4>
<pre>undefinedThe specified selector does not match any element in the DOM tree.

Browser: Firefox 47 / Mac OS X 10.10.1 </pre></div></body></html>
108 changes: 55 additions & 53 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,51 +83,53 @@ function defaultFunction() {
}

// TestID
this.tableReports += this.indentString('<td>', 2);
if (result === 'failed') {
this.tableReports += this.indentString(`<a href="#${testID}">`, 4);
this.tableReports += testID;
this.tableReports += '</a>\n';
} else {
this.tableReports += testID;
}
this.tableReports += '</td>\n';
// Fixture
this.tableReports += this.indentString('<td>', 2);
this.tableReports += this.currentFixtureName;
this.tableReports += '</td>\n';
// Test
this.tableReports += this.indentString('<td>', 2);
this.tableReports += name;
this.tableReports += '</td>\n';
// Browsers
this.tableReports += this.indentString('<td>', 2);
this.tableReports += this.uaList;
this.tableReports += '</td>\n';
// Duration
this.tableReports += this.indentString('<td>', 2);
this.tableReports += this.moment.duration(testRunInfo.durationMs).format('h[h] mm[m] ss[s]');
this.tableReports += '</td>\n';
// Result
this.tableReports += this.indentString('<td>', 2);
if (testRunInfo.skipped) {
this.tableReports += 'skipped';
} else {
this.tableReports += result;
if (result === 'failed' || testRunInfo.skipped) {
this.tableReports += this.indentString('<td>', 2);
if (result === 'failed') {
this.tableReports += this.indentString(`<a href="#${testID}">`, 4);
this.tableReports += testID;
this.tableReports += '</a>\n';
}
this.tableReports += '</td>\n';
// Fixture
this.tableReports += this.indentString('<td>', 2);
this.tableReports += this.currentFixtureName;
this.tableReports += '</td>\n';
// Test
this.tableReports += this.indentString('<td>', 2);
this.tableReports += name;
this.tableReports += '</td>\n';
// Duration
this.tableReports += this.indentString('<td>', 2);
this.tableReports += this.moment.duration(testRunInfo.durationMs).format('h[h] mm[m] ss[s]');
this.tableReports += '</td>\n';
// Result
this.tableReports += this.indentString('<td>', 2);
if (testRunInfo.skipped) {
this.tableReports += 'skipped';
} else if (result === 'failed') {
testRunInfo.errs.forEach((error) => {
this.tableReports += this.indentString('<div style="width:400px;overflow:auto">');
this.tableReports += this.indentString('<pre>');
this.tableReports += this.formatError(error, '');
this.tableReports += this.indentString('</pre>');
this.tableReports += this.indentString('</div>');
});
}
this.tableReports += '</td>\n';
// Screenshot
this.tableReports += this.indentString('<td>', 2);
if (result === 'failed') {
this.tableReports += this.indentString(`<a href="${screenshotPathPattern}/${testID}.png">`, 4);
this.tableReports += this.indentString('screenshot', 6);
this.tableReports += this.indentString('</a>\n');
} else {
this.tableReports += 'no screenshot';
}
this.tableReports += '</td>\n';

this.tableReports += this.indentString('</tr>\n');
}
this.tableReports += '</td>\n';
// Screenshot
this.tableReports += this.indentString('<td>', 2);
if (result === 'failed') {
this.tableReports += this.indentString(`<a href="${screenshotPathPattern}/${testID}.png">`, 4);
this.tableReports += this.indentString(`<img src="${screenshotPathPattern}/thumbnails/${testID}.png" img>\n`, 6);
this.tableReports += this.indentString('</a>\n');
} else {
this.tableReports += 'no screenshot';
}
this.tableReports += '</td>\n';

this.tableReports += this.indentString('</tr>\n');
},

reportTaskDone(endTime, passed/* , warnings */) {
Expand All @@ -153,20 +155,20 @@ function defaultFunction() {
html += `<p class="lead">Start Time: ${this.startTime}</p>`;
html += `<p class="lead">Browsers: ${this.uaList}</p>`;
html += `<p class="lead">Duration: ${durationStr}</p>`;
html += `<p class="lead">Tests Failed: ${failed} out of ${this.testCount}</p>`;
html += `<p class="lead">Tests Passed: ${passed}</p>`;
html += `<p class="lead">Tests Failed: ${failed}</p>`;
html += `<p class="lead">Tests Skipped: ${this.skipped}</p>`;
html += '</div><br>';

// Summary table
html += '<table class="table ">';
html += '<table class="table" border=1 frame=hsides rules=rows width=80%>';
html += '<tr>';
html += '<th>Test ID</th>';
html += '<th>Fixture</th>';
html += '<th>Test Name</th>';
html += '<th>Browser</th>';
html += '<th>Duration</th>';
html += '<th>Result</th>';
html += '<th>Screenshot</th>';
html += '<th width=5%>Test ID</th>';
html += '<th width=20%>Fixture</th>';
html += '<th width=20%>Test Name</th>';
html += '<th width=5%>Duration</th>';
html += '<th width=40%>Result</th>';
html += '<th width=10%>Screenshot</th>';
html += '</tr>';
html += this.tableReports;
html += '</table>';
Expand Down

0 comments on commit ceeff4c

Please sign in to comment.