Skip to content

Commit 9aa0b8f

Browse files
committed
percy - try static.options.execute.beforeSnapshot
1 parent c2f1a66 commit 9aa0b8f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/percy/snapshots.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ version: 2
22
static:
33
options:
44
waitForTimeout: 6000
5+
execute:
6+
beforeSnapshot: |
7+
const stash = window._canvasStash = [];
8+
Array.from(document.querySelectorAll('canvas')).forEach(c => {
9+
const i = document.createElement('img');
10+
i.src = c.toDataURL();
11+
i.width = c.width;
12+
i.height = c.height;
13+
i.setAttribute('style', c.getAttribute('style'));
14+
i.className = c.className;
15+
i.setAttribute('data-canvasnum', stash.length);
16+
stash.push(c);
17+
c.parentElement.insertBefore(i, c);
18+
c.parentElement.removeChild(c);
19+
});
520
snapshot:
621
widths:
722
- 1280

0 commit comments

Comments
 (0)