mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Chore: Adds neccessary packages * Wip: Initial dummy test in place * Feature: Downloads Chromium if needed * Fix: Adds global config object * Refactor: Adds basic e2eScenario * Build: Adds end to end tests to config * Build: Changes end to end job * Build: Adds browsers to image * Build: Adds failing test * Refactor: Adds first e2e-test scenario * Fix: Ignores test output in gitignore * Refactor: Adds compare screenshots ability * Refactor: Removes unnecessary code * Build: Removes jest-puppeteer * Fix: Replaces test snapshots * Refactor: Creates output dir if missing * Refactor: Changes aria-labels to be more consistent * Docs: Adds section about end to end tests * Fix: Fixes snapshots * Docs: Adds information about ENV variables
30 lines
864 B
TypeScript
30 lines
864 B
TypeScript
import puppeteer, { Browser } from 'puppeteer-core';
|
|
|
|
export const launchBrowser = async (): Promise<Browser> => {
|
|
const browserFetcher = puppeteer.createBrowserFetcher();
|
|
const localRevisions = await browserFetcher.localRevisions();
|
|
if (localRevisions.length === 0) {
|
|
throw new Error('Could not launch browser because there is no local revisions.');
|
|
}
|
|
|
|
let executablePath = null;
|
|
executablePath = browserFetcher.revisionInfo(localRevisions[0]).executablePath;
|
|
|
|
const browser = await puppeteer.launch({
|
|
headless: process.env.BROWSER ? false : true,
|
|
slowMo: process.env.SLOWMO ? 100 : 0,
|
|
defaultViewport: {
|
|
width: 1920,
|
|
height: 1080,
|
|
deviceScaleFactor: 1,
|
|
isMobile: false,
|
|
hasTouch: false,
|
|
isLandscape: false,
|
|
},
|
|
args: ['--start-fullscreen'],
|
|
executablePath,
|
|
});
|
|
|
|
return browser;
|
|
};
|