fix(core): update

This commit is contained in:
Philipp Kunz 2022-07-18 03:08:32 +02:00
parent d4232decdd
commit b6472f38e2
3 changed files with 20 additions and 4 deletions

View File

@ -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();
});

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartpuppeteer',
version: '2.0.1',
version: '2.0.2',
description: 'simplified access to puppeteer'
}

View File

@ -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 = {};