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

Function runTestPage

test/runTest/cli.js:175–361  ·  view source on GitHub ↗

* @param {puppeteer.Browser} browser

(browser, testOpt, source, version, runtimeCode, isExpected)

Source from the content-addressed store, hash-verified

173 * @param {puppeteer.Browser} browser
174 */
175async function runTestPage(browser, testOpt, source, version, runtimeCode, isExpected) {
176 const fileUrl = testOpt.fileUrl;
177 const screenshots = [];
178 const logs = [];
179 const errors = []; // string[]
180
181 const page = await browser.newPage();
182 page.setRequestInterception(true);
183 page.on('request', request => replaceEChartsVersion(request, source, version));
184
185 async function pageScreenshot() {
186 if (!program.save) {
187 return;
188 }
189 // Final shot.
190 await page.mouse.move(0, 0);
191 const desc = 'Full Shot';
192 const {
193 screenshotName,
194 screenshotPath,
195 rawScreenshotPath
196 } = await takeScreenshot(page, true, fileUrl, desc, isExpected);
197 screenshots.push({
198 screenshotName,
199 desc,
200 screenshotPath,
201 rawScreenshotPath
202 });
203 }
204
205 let vstInited = false;
206
207 await page.exposeFunction('__VRT_INIT__', () => {
208 vstInited = true;
209 });
210 await page.exposeFunction('__VRT_MOUSE_MOVE__', async (x, y) => {
211 await page.mouse.move(x, y);
212 });
213 await page.exposeFunction('__VRT_MOUSE_DOWN__', async (errMsgPart) => {
214 try {
215 await page.mouse.down();
216 }
217 catch (err) {
218 // e.g., if double mousedown without a mouseup, error "'left' is already pressed." will be thrown.
219 // Report to users to re-record the test case.
220 if (errMsgPart) {
221 if ((err.message + '').indexOf('already pressed') >= 0) {
222 errMsgPart += ' May be caused by duplicated mousedowns without a mouseup.'
223 + ' Please re-record the test case.';
224 }
225 err.message = err.message + ' ' + errMsgPart;
226 }
227 throw err;
228 }
229 });
230 await page.exposeFunction('__VRT_MOUSE_UP__', async (errMsgPart) => {
231 try {
232 await page.mouse.up();

Callers 1

runTestFunction · 0.85

Calls 6

replaceEChartsVersionFunction · 0.85
pageScreenshotFunction · 0.85
takeScreenshotFunction · 0.85
closeMethod · 0.80
evaluateMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…