MCPcopy
hub / github.com/apache/echarts / takeScreenshot

Function takeScreenshot

test/runTest/cli.js:117–150  ·  view source on GitHub ↗
(page, fullPage, fileUrl, desc, isExpected, minor)

Source from the content-addressed store, hash-verified

115}
116
117async 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
152async function waitForNetworkIdle(page) {
153 let count = 0;

Callers 3

pageScreenshotFunction · 0.85
runTestPageFunction · 0.85
_updateMethod · 0.85

Calls 2

getScreenshotDirFunction · 0.85
convertToWebPFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…