(page, fullPage, fileUrl, desc, isExpected, minor)
| 115 | } |
| 116 | |
| 117 | async function takeScreenshot(page, fullPage, fileUrl, desc, isExpected, minor) { |
| 118 | let screenshotName = testNameFromFile(fileUrl); |
| 119 | if (desc) { |
| 120 | screenshotName += '-' + slugify(desc, { replacement: '-', lower: true }); |
| 121 | } |
| 122 | if (minor) { |
| 123 | screenshotName += '-' + minor; |
| 124 | } |
| 125 | const screenshotPrefix = isExpected ? 'expected' : 'actual'; |
| 126 | fse.ensureDirSync(getScreenshotDir()); |
| 127 | const screenshotPath = path.join(getScreenshotDir(), `${screenshotName}-${screenshotPrefix}.png`); |
| 128 | await page.screenshot({ |
| 129 | path: screenshotPath, |
| 130 | // https://github.com/puppeteer/puppeteer/issues/7043 |
| 131 | // https://github.com/puppeteer/puppeteer/issues/6921#issuecomment-829586680 |
| 132 | captureBeyondViewport: false, |
| 133 | fullPage |
| 134 | }); |
| 135 | |
| 136 | let webpScreenshotPath; |
| 137 | try { |
| 138 | webpScreenshotPath = await convertToWebP(screenshotPath); |
| 139 | } catch (e) { |
| 140 | console.error('Failed to convert screenshot to webp', e); |
| 141 | } |
| 142 | |
| 143 | console.log('Screenshot: ', webpScreenshotPath || screenshotPath); |
| 144 | |
| 145 | return { |
| 146 | screenshotName, |
| 147 | screenshotPath: webpScreenshotPath || screenshotPath, |
| 148 | rawScreenshotPath: screenshotPath |
| 149 | }; |
| 150 | } |
| 151 | |
| 152 | async function waitForNetworkIdle(page) { |
| 153 | let count = 0; |
no test coverage detected
searching dependent graphs…