From e2b96df4d73383bdcd46ee2e60b0e08ee965b0a5 Mon Sep 17 00:00:00 2001 From: JoelEinbinder Date: Fri, 23 Feb 2018 15:54:26 -0800 Subject: [PATCH] chore(test): simplify element screenshot tests (#2093) --- ...creenshot-element-larger-than-viewport.png | Bin 1274 -> 2807 bytes ...reenshot-element-with-scroll-container.png | Bin 2521 -> 0 bytes test/test.js | 88 +----------------- 3 files changed, 4 insertions(+), 84 deletions(-) delete mode 100644 test/golden/screenshot-element-with-scroll-container.png diff --git a/test/golden/screenshot-element-larger-than-viewport.png b/test/golden/screenshot-element-larger-than-viewport.png index 4842968bd9c457da894945288c12ca0eda2c130b..5fcdb923555dcdff72047ca5a53974015cb17b6e 100644 GIT binary patch literal 2807 zcmeAS@N?(olHy`uVBq!ia0y~yV2T1^4mP03_vn|e7#O(rdAc};RLpsM?I7m?1Azk@ zykGv)UhaK`rOBjmew=YNKLf-5>hv{Y3|>mU^ExdB^RWeeN$`2#PGmPUZ{j?^1jKr#RT diff --git a/test/golden/screenshot-element-with-scroll-container.png b/test/golden/screenshot-element-with-scroll-container.png deleted file mode 100644 index c7860b32a28af62c06500082a9d7bde0deb5da1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2521 zcmeAS@N?(olHy`uVBq!ia0y~yVDbQA4mP03EIH}*3=EtLJY5_^D(1Ysv61(%0}qSi zse=2PwCY*gWOJC;C#WS=JZw6CCW@Ki!2Rs+3=9p+EC2U>{`2MzBg2NfrM1;3*f|*# zScDiHI8+!K1b}8MPGDegQeb3gabRNLXk=j!U>a308V;lBVKiTimJg%l { - // compare with .to-screenshot size await page.setViewport({width: 500, height: 500}); await page.setContent(` something above - -
-
`); - - await page.evaluate(function() { - window.scrollTo(11, 12); - }); - const elementHandle = await page.$('div.to-screenshot'); const screenshot = await elementHandle.screenshot(); expect(screenshot).toBeGolden('screenshot-element-larger-than-viewport.png'); - expect(await page.evaluate(function() { - return { w: window.innerWidth, h: window.innerHeight }; - })).toEqual({ w: 500, h: 500 }); - }); - it('should screenshot element with scroll container', async({page, server}) => { - // compare with .to-screenshot size - await page.setViewport({width: 500, height: 500}); - - await page.setContent(` - something above - -
-
-
-
-
-
-
- `); - - await page.evaluate(function() { - window.scrollTo(11, 12); - }); - - await page.$eval('div.container1', function(element) { - element.scrollTo(100, 0); - }); - - await page.$eval('div.container2', function(element) { - element.scrollTo(10, 30); - }); - - const elementHandle = await page.$('div.to-screenshot'); - const screenshot = await elementHandle.screenshot(); - expect(screenshot).toBeGolden('screenshot-element-with-scroll-container.png'); + expect(await page.evaluate(() => ({ w: window.innerWidth, h: window.innerHeight }))).toEqual({ w: 500, h: 500 }); }); it('should scroll element into view', async({page, server}) => { await page.setViewport({width: 500, height: 500});