-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr-tests-v9): don't open browser twice on CI to potentially miti…
…gate TIMEOUT issues (#26587)
- Loading branch information
Showing
1 changed file
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,39 @@ | ||
import { isCI } from 'ci-info'; | ||
import { launchBrowser } from './launchBrowser'; | ||
|
||
/** | ||
* https://github.com/puppeteer/puppeteer/blob/main/versions.js | ||
*/ | ||
const CHROMIUM_VERSION = 'HeadlessChrome/110.0.5479.0'; | ||
const staticVersion = normalizeChromiumVersion(CHROMIUM_VERSION); | ||
|
||
export async function getChromeVersion(): Promise<number> { | ||
// this is a temporary solution to test if lanunching browser only once will mitigate TIMEOUT ISSUES ON CI | ||
if (isCI) { | ||
return staticVersion; | ||
} | ||
|
||
const browser = await launchBrowser(); | ||
const version = normalizeChromiumVersion(await browser.version()); | ||
await browser.close(); | ||
|
||
// includes browser name, example: HeadlessChrome/103.0.5058.0 | ||
const rawVersion = await browser.version(); | ||
const version = rawVersion.split('/')[1].split('.')[0]; | ||
if (version !== staticVersion) { | ||
throw new Error( | ||
`puppeteer uses different Chromium version! | ||
puppeteer: ${version} , chromium_version constant: ${staticVersion} | ||
await browser.close(); | ||
Please update CHROMIUM_VERSION constant to match puppeteer installed version https://github.com/puppeteer/puppeteer/blob/main/versions.js.`, | ||
); | ||
} | ||
|
||
return version; | ||
} | ||
|
||
return parseInt(version, 10); | ||
/** | ||
* | ||
* @param value - includes browser name, example: HeadlessChrome/103.0.5058.0 | ||
* @returns | ||
*/ | ||
function normalizeChromiumVersion(value: string) { | ||
return Number(value.split('/')[1].split('.')[0]); | ||
} |