Skip to content

Commit 3d54373

Browse files
authored
Merge pull request #24 from michaelchadwick/improve-output-styling
Improved output styling and such
2 parents d2e2377 + 42250b4 commit 3d54373

2 files changed

Lines changed: 42 additions & 26 deletions

File tree

templates/report.html

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,24 @@
1010
gap: 1rem;
1111
margin: 1rem 0;
1212
}
13-
1413
.diff-images img {
1514
max-width: 30vw;
1615
height: auto;
1716
}
17+
details {
18+
margin-bottom: 1em;
19+
}
20+
summary {
21+
cursor: pointer;
22+
font-size: 1.17em;
23+
font-weight: bold;
24+
}
1825
</style>
1926
</head>
2027
<body>
2128
<main>
2229
<h1>Visual Diff Report</h1>
23-
2430
<p><strong>Status:</strong> <span aria-hidden="true">{{statusEmoji}}</span> {{statusText}}</p>
25-
2631
<h2>Summary</h2>
2732
<ul>
2833
<li><strong>Total Images:</strong> {{totalImages}}</li>
@@ -32,7 +37,7 @@ <h2>Summary</h2>
3237
<li><strong>Identical:</strong> {{identicalCount}}</li>
3338
</ul>
3439

35-
{{#if withDifferences.length}}
40+
{{#if withDifferences.length}}
3641
<h2>Images with Differences ({{withDifferences.length}})</h2>
3742
{{#each withDifferences}}
3843
<div>
@@ -44,41 +49,49 @@ <h3>{{name}}</h3>
4449
{{/if}}
4550
<div class="diff-images">
4651
<a href="{{baselineImage}}"><img src="{{baselineImage}}" alt="Baseline screenshot for {{name}}" /></a>
52+
{{#unless dimensionMismatch}}
4753
<a href="{{diffImage}}"><img src="{{diffImage}}" alt="Visual difference highlighting changed pixels in {{name}}"/></a>
54+
{{/unless}}
4855
<a href="{{candidateImage}}"><img src="{{candidateImage}}" alt="Candidate screenshot for {{name}}" /></a>
4956
</div>
5057
</div>
5158
{{/each}}
52-
{{/if}}
59+
{{/if}}
5360

54-
{{#if hasRemovedOrAdded}}
61+
{{#if hasRemovedOrAdded}}
5562
<h2>Missing or New Files</h2>
56-
{{#if baselineOnly.length}}
57-
<h3>Removed from Candidate ({{baselineOnly.length}})</h3>
58-
<ul>
59-
{{#each baselineOnly}}
60-
<li>{{name}}</li>
61-
{{/each}}
62-
</ul>
63+
{{#if baselineOnly.length}}
64+
<details>
65+
<summary>Removed from Candidate ({{baselineOnly.length}})</summary>
66+
<ul>
67+
{{#each baselineOnly}}
68+
<li>{{name}}</li>
69+
{{/each}}
70+
</ul>
71+
</details>
72+
{{/if}}
73+
{{#if candidateOnly.length}}
74+
<details>
75+
<summary>Added in Candidate ({{candidateOnly.length}})</summary>
76+
<ul>
77+
{{#each candidateOnly}}
78+
<li>{{name}}</li>
79+
{{/each}}
80+
</ul>
81+
</details>
82+
{{/if}}
6383
{{/if}}
64-
{{#if candidateOnly.length}}
65-
<h3>Added in Candidate ({{candidateOnly.length}})</h3>
84+
85+
{{#if withoutDifferences.length}}
86+
<details>
87+
<summary>Identical Images ({{withoutDifferences.length}})</summary>
6688
<ul>
67-
{{#each candidateOnly}}
89+
{{#each withoutDifferences}}
6890
<li>{{name}}</li>
6991
{{/each}}
7092
</ul>
93+
</details>
7194
{{/if}}
72-
{{/if}}
73-
74-
{{#if withoutDifferences.length}}
75-
<h2>Identical Images ({{withoutDifferences.length}})</h2>
76-
<ul>
77-
{{#each withoutDifferences}}
78-
<li>{{name}}</li>
79-
{{/each}}
80-
</ul>
81-
{{/if}}
8295

8396
<hr>
8497
<p><em>Generated by visual-differ</em></p>

test/report-generator.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ describe('report-generator', () => {
9494
expect(html).toContain('Dimension mismatch');
9595
expect(html).toContain('10x20');
9696
expect(html).toContain('20x30');
97+
expect(html).toContain('mismatched-baseline.png');
98+
expect(html).not.toContain('mismatched-diff.png');
99+
expect(html).toContain('mismatched-candidate.png');
97100
});
98101

99102
it('should show status indicator', () => {

0 commit comments

Comments
 (0)