Browse Source

Puppeteer E2E test: Replace BrowserFetcher with @puppeteer/browsers (#26282)

* Puppeteer E2E test: Replace BrowserFetcher with @puppeteer/browsers

* Cleanup

* Fix dependency

* Remove unused function
Levi Pesin 2 years ago
parent
commit
36243d15a3
3 changed files with 765 additions and 28 deletions
  1. 749 11
      package-lock.json
  2. 1 0
      package.json
  3. 15 17
      test/e2e/puppeteer.js

File diff suppressed because it is too large
+ 749 - 11
package-lock.json


+ 1 - 0
package.json

@@ -84,6 +84,7 @@
   },
   "homepage": "https://threejs.org/",
   "devDependencies": {
+    "@puppeteer/browsers": "^1.4.1",
     "@rollup/plugin-node-resolve": "^15.0.1",
     "@rollup/plugin-terser": "^0.4.0",
     "chalk": "^5.2.0",

+ 15 - 17
test/e2e/puppeteer.js

@@ -1,5 +1,6 @@
 import chalk from 'chalk';
-import puppeteer, { BrowserFetcher } from 'puppeteer-core';
+import puppeteer from 'puppeteer-core';
+import { install, computeExecutablePath/*, resolveBuildId*/, detectBrowserPlatform } from '@puppeteer/browsers';
 import express from 'express';
 import path from 'path';
 import pixelmatch from 'pixelmatch';
@@ -137,7 +138,8 @@ const exceptionList = [
 
 /* CONFIG VARIABLES END */
 
-const chromiumRevision = '1108766'; // Chromium 112.0.5614.0, Puppeteer 19.8.0, https://github.com/puppeteer/puppeteer/releases/tag/puppeteer-core-v19.8.0
+const chromiumChannel = 'stable'; // stable -- beta -- dev -- canary -- latest
+const installedBrowsersDir = 'test/e2e/chromium';
 
 const port = 1234;
 const pixelThreshold = 0.1; // threshold error in one pixel
@@ -173,7 +175,7 @@ process.on( 'SIGINT', () => close() );
 
 async function main() {
 
-	/* Create output directories */
+	/* Create output directory */
 
 	try { await fs.rm( 'test/e2e/output-screenshots', { recursive: true, force: true } ); } catch {}
 	try { await fs.mkdir( 'test/e2e/output-screenshots' ); } catch {}
@@ -221,7 +223,7 @@ async function main() {
 
 	/* Download browser */
 
-	const { executablePath } = await downloadLatestChromium();
+	const executablePath = await downloadLatestChromium();
 
 	/* Launch browser */
 
@@ -300,24 +302,20 @@ async function main() {
 
 async function downloadLatestChromium() {
 
-	const browserFetcher = new BrowserFetcher( { path: 'test/e2e/chromium' } );
+	platform = detectBrowserPlatform();
 
-	platform = browserFetcher.platform();
+	const revision = '1108766'; //await resolveBuildId( 'chromium', platform, chromiumChannel );
+	                            // the Chromium snapshots server doesn't work properly currently so fix the revision
+	const options = { browser: 'chromium', buildId: revision, cacheDir: path.resolve( installedBrowsersDir ) };
 
-	let revisionInfo = browserFetcher.revisionInfo( chromiumRevision );
-	if ( revisionInfo.local === true ) {
+	console.log( `Using Chromium r${ revision }, ${ chromiumChannel } channel on ${ platform }` );
+	console.log( 'Downloading...' );
 
-		console.log( 'Latest Chromium has been already downloaded.' );
+	await install( options );
 
-	} else {
-
-		console.log( 'Downloading latest Chromium...' );
-		revisionInfo = await browserFetcher.download( chromiumRevision );
-		console.log( 'Downloaded.' );
+	console.log( 'Downloaded.' );
 
-	}
-	console.log( `Using Chromium r${ chromiumRevision } (${ revisionInfo.url }), stable channel on ${ platform }` );
-	return revisionInfo;
+	return computeExecutablePath( options );
 
 }
 

Some files were not shown because too many files changed in this diff