MCPcopy Index your code
hub / github.com/apache/echarts / runTest

Function runTest

test/runTest/cli.js:375–451  ·  view source on GitHub ↗

* @param {puppeteer.Browser} browser

(browser, testOpt, runtimeCode, expectedSource, expectedVersion, actualSource, actualVersion)

Source from the content-addressed store, hash-verified

373 * @param {puppeteer.Browser} browser
374 */
375async function runTest(browser, testOpt, runtimeCode, expectedSource, expectedVersion, actualSource, actualVersion) {
376 if (program.save) {
377 testOpt.status === 'running';
378
379 const expectedResult = await runTestPage(browser, testOpt, expectedSource, expectedVersion, runtimeCode, true);
380 const actualResult = await runTestPage(browser, testOpt, actualSource, actualVersion, runtimeCode, false);
381
382 // sortScreenshots(expectedResult.screenshots);
383 // sortScreenshots(actualResult.screenshots);
384
385 const screenshots = [];
386 let idx = 0;
387 for (let shot of expectedResult.screenshots) {
388 const expected = shot;
389 const actual = actualResult.screenshots[idx++];
390 const result = {
391 actual: getClientRelativePath(actual.screenshotPath),
392 expected: getClientRelativePath(expected.screenshotPath),
393 name: actual.screenshotName,
394 desc: actual.desc
395 };
396 try {
397 const {diffRatio, diffPNG} = await compareScreenshot(
398 expected.rawScreenshotPath,
399 actual.rawScreenshotPath
400 );
401
402 const diffPath = `${getScreenshotDir()}/${shot.screenshotName}-diff.png`;
403 await writePNG(diffPNG, diffPath);
404
405 let diffWebpPath;
406 try {
407 diffWebpPath = await convertToWebP(diffPath);
408 } catch (e) {
409 console.error('Failed to convert diff png to webp', e);
410 }
411
412 result.diff = getClientRelativePath(diffWebpPath || diffPath);
413 result.diffRatio = diffRatio;
414
415 // Remove png files
416 try {
417 await Promise.all([
418 fse.unlink(actual.rawScreenshotPath),
419 fse.unlink(expected.rawScreenshotPath),
420 diffWebpPath && fse.unlink(diffPath)
421 ]);
422 }
423 catch (e) {}
424 }
425 catch(e) {
426 result.diff = '';
427 result.diffRatio = 1;
428 console.log(e);
429 }
430
431 screenshots.push(result);
432 }

Callers 1

eachTaskFunction · 0.85

Calls 5

runTestPageFunction · 0.85
getClientRelativePathFunction · 0.85
getScreenshotDirFunction · 0.85
writePNGFunction · 0.85
convertToWebPFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…