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

Feature expand functionality #1

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
"git add"
]
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"dependencies": {},
"devDependencies": {
"callsite-record": "^4.1.3",
Expand All @@ -51,18 +46,9 @@
"testcafe": "^1.5.0",
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.6.2",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"eslint": "^6.5.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"husky": "^4.2.3",
"lint-staged": "^9.4.2"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
}
}
49 changes: 16 additions & 33 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = () => ({
noColors: true,
startTime: null,
afterErrList: false,
uaList: null,
report: '',
table: '',
tableReports: '',
Expand All @@ -17,7 +16,6 @@ module.exports = () => ({

reportTaskStart: function reportTaskStart(startTime, userAgents, testCount) {
this.startTime = startTime;
this.uaList = userAgents.join(', ');
this.testCount = testCount;
},

Expand All @@ -27,7 +25,7 @@ module.exports = () => ({

reportTestDone: function reportTestDone(name, testRunInfo) {
const hasErr = !!testRunInfo.errs.length;
const result = hasErr ? 'failed' : 'passed';
const result = hasErr ? '失敗' : '成功';

if (testRunInfo.skipped) {
this.skipped += 1;
Expand Down Expand Up @@ -74,27 +72,22 @@ module.exports = () => ({

// Fixture
this.tableReports += this.indentString('<td>', 2);
this.tableReports += this.currentFixtureName;
this.tableReports += this.currentFixtureName.replace(/\r?\n/g, '<br>\n');;
this.tableReports += '</td>\n';
// Test
this.tableReports += this.indentString('<td>', 2);
this.tableReports += name;
this.tableReports += name.replace(/\r?\n/g, '<br>\n');
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 += this.moment.duration(testRunInfo.durationMs).format('h[時間] mm[] ss[]');
this.tableReports += '</td>\n';
// Result
this.tableReports += this.indentString('<td>', 2);
if (testRunInfo.skipped) {
this.tableReports += 'skipped';
} else if (result === 'failed') {
this.tableReports += `<a href="#test-${this.currentTestNumber}">failed</a>`;
} else if (result === '失敗') {
this.tableReports += `<a href="#test-${this.currentTestNumber}">失敗</a>`;
} else {
this.tableReports += result;
}
Expand All @@ -104,9 +97,9 @@ module.exports = () => ({
this.tableReports += this.indentString('</tr>\n');
},

reportTaskDone: function reportTaskDone(endTime, passed /* , warnings */) {
reportTaskDone: function reportTaskDone(endTime, passed) {
const durationMs = endTime - this.startTime;
const durationStr = this.moment.duration(durationMs).format('h[h] mm[m] ss[s]');
const durationStr = this.moment.duration(durationMs).format('h[時間] mm[] ss[]');
const failed = this.testCount - passed;

// Opening html
Expand Down Expand Up @@ -184,28 +177,19 @@ module.exports = () => ({

// Now add a summary
html += `
<h1 class="text-primary">TestCafe Test Summary</h1>
<div class="client-logo" style="padding:15px"></div>
<div class="bg-primary" style="padding:15px;box-shadow: 6px 6px 6px 6px #00000033;border-radius: 10px;">
<h3>Summary</h3><br>
<p class="lead">Start Time: ${this.startTime}</p>
<p class="lead">Browsers: ${this.uaList}</p>
<p class="lead">Duration: ${durationStr}</p>
<p class="lead">Tests Failed: ${failed} out of ${this.testCount}</p>
<p class="lead">Tests Skipped: ${this.skipped}</p>
</div><br>`;
<h1 class="text-primary">TestCafe</h1>
<div class="client-logo" style="padding:15px"></div>`;

// Summary table
html += `
<table class="table sortable" style="padding:15px;box-shadow: 6px 6px 6px 6px #00000033;border-radius: 10px;">
<thead>
<tr>
<th>#</th>
<th>Fixture</th>
<th>Test Name</th>
<th>Browsers</th>
<th>Duration</th>
<th>Result</th>
<th>画面</th>
<th>項目</th>
<th>所要時間</th>
<th>結果</th>
</tr>
</thead>
<tbody>
Expand All @@ -216,9 +200,8 @@ module.exports = () => ({
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>${durationStr}</th>
<th>${this.testCount - failed} / ${this.testCount}</th>
</tr>
</thead>
</table>
Expand Down
70 changes: 31 additions & 39 deletions test/data/report-with-colors.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,83 +70,76 @@
</div>
<div class="container">

<h1 class="text-primary">TestCafe Test Summary</h1>
<h1 class="text-primary">TestCafe</h1>
<div class="client-logo" style="padding:15px"></div>
<div class="bg-primary" style="padding:15px;box-shadow: 6px 6px 6px 6px #00000033;border-radius: 10px;">
<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 sortable" style="padding:15px;box-shadow: 6px 6px 6px 6px #00000033;border-radius: 10px;">
<thead>
<tr>
<th>#</th>
<th>Fixture</th>
<th>Test Name</th>
<th>Browsers</th>
<th>Duration</th>
<th>Result</th>
<th>画面</th>
<th>項目</th>
<th>所要時間</th>
<th>結果</th>
</tr>
</thead>
<tbody>
<tr class="success">
<td>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>First test in first fixture<br>
this is new line test</td>
<td>1分 14秒</td>
<td>成功</td>
</tr>
<tr class="danger">
<td>2</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><a href="#test-2">failed</a></td>
<td>1分 14秒</td>
<td><a href="#test-2">失敗</a></td>
</tr>
<tr class="success">
<td>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>1分 14秒</td>
<td>成功</td>
</tr>
<tr class="success">
<td>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>1分 14秒</td>
<td>成功</td>
</tr>
<tr class="success">
<td>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>1分 14秒</td>
<td>成功</td>
</tr>
<tr class="success">
<td>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>0秒</td>
<td>成功</td>
</tr>
<tr class="danger">
<td>7</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><a href="#test-7">failed</a></td>
<td>1分 14秒</td>
<td><a href="#test-7">失敗</a></td>
</tr>
<tr class="success">
<td>8</td>
<td>Forth fixture<br>
this is new line test</td>
<td>Forth test in first fixture</td>
<td>0秒</td>
<td>成功</td>
</tr>

</tbody>
Expand All @@ -155,9 +148,8 @@ <h3>Summary</h3><br>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>0秒</th>
<th>4 / 6</th>
</tr>
</thead>
</table>
Expand Down
24 changes: 23 additions & 1 deletion test/utils/reporter-test-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = [
{
method: 'reportTestDone',
args: [
'First test in first fixture',
`First test in first fixture
this is new line test`,
{
errs: [],
durationMs: 74000,
Expand Down Expand Up @@ -161,6 +162,27 @@ module.exports = [
},
],
},
{
method: 'reportFixtureStart',
args: [
`Forth fixture
this is new line test`,
'./fixture4.js',
],
},
{
method: 'reportTestDone',
args: [
'Forth test in first fixture',
{
errs: [],
durationMs: 0,
unstable: false,
screenshotPath: null,
skipped: false,
},
],
},
{
method: 'reportTaskDone',
args: [
Expand Down
Loading