fix(core): update
This commit is contained in:
parent
d4232decdd
commit
b6472f38e2
19
test/test.ts
19
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();
|
||||
});
|
||||
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartpuppeteer',
|
||||
version: '2.0.1',
|
||||
version: '2.0.2',
|
||||
description: 'simplified access to puppeteer'
|
||||
}
|
||||
|
@ -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 = {};
|
||||
|
Loading…
Reference in New Issue
Block a user