Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to Playwright 0.12.1 and update other deps #71

Merged
merged 10 commits into from
Mar 24, 2020
208 changes: 72 additions & 136 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"author": "Max Schmitt <max@schmitt.mx>",
"license": "MIT",
"dependencies": {
"@sentry/node": "^5.13.0",
"@sentry/node": "^5.15.0",
"bottleneck": "^2.19.5",
"express": "^4.17.1",
"ffmpeg-static": "^4.0.1",
"mime-types": "^2.1.26",
"playwright": "^0.11.1-next.1583993157193",
"playwright-core": "^0.11.1-next.1583993157193",
"playwright-video": "^0.5.0",
"sqlite": "^3.0.3",
"playwright": "^0.11.1-next.1584947279674",
"playwright-core": "^0.11.1-next.1584947279674",
"playwright-video": "^0.7.0",
"sqlite": "^3.0.6",
"sqlite3": "^4.1.1",
"typescript": "^3.8.3",
"uuid": "^7.0.1",
"vm2": "^3.8.4"
"uuid": "^7.0.2",
"vm2": "^3.9.0"
},
"scripts": {
"build": "tsc",
Expand All @@ -29,12 +29,12 @@
"test": "jest"
},
"devDependencies": {
"@sentry/types": "5.14.2",
"@sentry/types": "5.15.0",
"@types/debug": "4.1.5",
"@types/express": "4.17.3",
"@types/jest": "25.1.4",
"@types/mime-types": "2.1.0",
"@types/node": "13.9.1",
"@types/node": "13.9.3",
"@types/sqlite3": "3.1.6",
"@types/uuid": "7.0.2",
"jest": "25.1.0",
Expand Down
17 changes: 15 additions & 2 deletions backend/src/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ import path from 'path'
import { EventEmitter } from 'events'
import { v4 as uuidv4 } from 'uuid'
import { Browser, WebKitBrowser } from 'playwright-core'
// @ts-ignore
import { Playwright } from 'playwright-core/lib/server/playwright'
// @ts-ignore
import { CRBrowser } from 'playwright-core/lib/chromium/crBrowser';
// @ts-ignore
import { CRPage } from 'playwright-core/lib/chromium/crPage';
// @ts-ignore
import { Page, FirefoxBrowser } from 'playwright-core/lib/api';
// @ts-ignore
import { ScreenshotOptions, PDFOptions } from 'playwright-core/lib/types';
// @ts-ignore
import { BufferType } from 'playwright-core/lib/platform';
// @ts-ignore
import { LaunchOptions } from 'playwright-core/lib/server/browserType';
// @ts-nocheck
import { saveVideo, PageVideoCapture } from 'playwright-video'

const BROWSER_ID = Symbol('BROWSER_ID');
Expand Down Expand Up @@ -82,12 +90,17 @@ const preBrowserLaunch = async (browser: Browser, id: string): Promise<void> =>
browser[BROWSER_ID] = id
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
const downloadedBrowsers = require(path.join(__dirname, "..", "node_modules", "playwright", ".downloaded-browsers.json"),)

export const getPlaywright = (id: string): Playwright => {
const pw = new Playwright({
downloadPath: path.join(__dirname, "..", "node_modules", "playwright"),
browsers: ['webkit', 'chromium', 'firefox'],
respectEnvironmentVariables: false,
});
pw.chromium._executablePath = downloadedBrowsers.crExecutablePath;
pw.firefox._executablePath = downloadedBrowsers.ffExecutablePath;
pw.webkit._executablePath = downloadedBrowsers.wkExecutablePath;

// @ts-ignore
const originalChromiumLaunch = pw.chromium.launch
// @ts-ignore
Expand Down