From b6472f38e21aa868ff7225ddd4c5bfe158545cae Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 18 Jul 2022 03:08:32 +0200 Subject: [PATCH] fix(core): update --- test/test.ts | 19 +++++++++++++++++-- ts/00_commitinfo_data.ts | 2 +- ts/smartpuppeteer.classes.smartpuppeteer.ts | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/test.ts b/test/test.ts index 0ccf15b..f2bfe41 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,11 +1,26 @@ import { expect, tap } from '@pushrocks/tapbundle'; import * as smartpuppeteer from '../ts/index.js'; -tap.test('first test', async (tools) => { +tap.test('should use pipe', async (tools) => { const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({ - forceNoSandbox: true, + forceNoSandbox: false, }); const page = await headlessBrowser.newPage(); + await page.goto('https://lossless.com'); + console.log(await page.title()); + expect(headlessBrowser.wsEndpoint()).toEqual(''); + await headlessBrowser.close(); +}); + +tap.test('should use websocket', async (tools) => { + const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({ + forceNoSandbox: false, + usePipe: false, + }); + const page = await headlessBrowser.newPage(); + await page.goto('https://lossless.com'); + console.log(await page.title()); + expect(headlessBrowser.wsEndpoint()).not.toEqual(''); await headlessBrowser.close(); }); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 3e504ad..bc77bf1 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@pushrocks/smartpuppeteer', - version: '2.0.1', + version: '2.0.2', description: 'simplified access to puppeteer' } diff --git a/ts/smartpuppeteer.classes.smartpuppeteer.ts b/ts/smartpuppeteer.classes.smartpuppeteer.ts index 59effc3..858fa89 100644 --- a/ts/smartpuppeteer.classes.smartpuppeteer.ts +++ b/ts/smartpuppeteer.classes.smartpuppeteer.ts @@ -2,6 +2,7 @@ import * as plugins from './smartpuppeteer.plugins.js'; export interface IEnvAwareOptions { forceNoSandbox?: boolean; + usePipe?: boolean; } export const getEnvAwareBrowserInstance = async ( @@ -24,7 +25,7 @@ export const getEnvAwareBrowserInstance = async ( console.log(chromeArgs); headlessBrowser = await plugins.puppeteer.launch({ args: chromeArgs, - pipe: true, + pipe: options.usePipe !== undefined ? options.usePipe : true, headless: true, ...(() => { const returnObject: any = {};