mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Introduce screenshot tests
This patch introduces a goldentest.js. The tests inside the file should rely on "golden" results rather then asserts. For now, goldentest.js allows only image expectations. If the actual result doesn't match the expected result, the two files are created under `test/output` folder: - The '-actual.png' contains the actual test result - The '-diff.png' contains the diff between images
This commit is contained in:
44
test/assets/grid.html
Normal file
44
test/assets/grid.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
function generatePalette(amount) {
|
||||
var result = [];
|
||||
var hueStep = 360 / amount;
|
||||
for (var i = 0; i < amount; ++i)
|
||||
result.push('hsl(' + (hueStep * i) + ', 100%, 90%)');
|
||||
return result;
|
||||
}
|
||||
|
||||
var palette = generatePalette(100);
|
||||
for (var i = 0; i < 1000; ++i) {
|
||||
var box = document.createElement('div');
|
||||
box.classList.add('box');
|
||||
box.textContent = i;
|
||||
box.style.setProperty('background-color', palette[i % palette.length]);
|
||||
document.body.appendChild(box);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
/* Hide scrollbar so that it is not captured on screenshots */
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.box {
|
||||
font-family: arial;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid darkgray;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user