smartpuppeteer/test/test.ts

35 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2024-04-12 11:13:09 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
2022-03-24 12:51:12 +00:00
import * as smartpuppeteer from '../ts/index.js';
2019-06-03 20:24:10 +00:00
2022-07-18 01:08:32 +00:00
tap.test('should use pipe', async (tools) => {
2019-11-15 17:59:29 +00:00
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
2022-07-18 01:08:32 +00:00
forceNoSandbox: false,
2019-11-15 17:59:29 +00:00
});
2021-08-17 13:22:10 +00:00
const page = await headlessBrowser.newPage();
2022-07-18 01:08:32 +00:00
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('');
2019-06-03 20:48:40 +00:00
await headlessBrowser.close();
2019-06-03 20:24:10 +00:00
});
2021-08-17 13:22:10 +00:00
tap.test('should get and stop an Incognito browser', async () => {
const incognitoInstance = new smartpuppeteer.IncognitoBrowser();
await incognitoInstance.start();
const page = await incognitoInstance.browser.newPage();
await incognitoInstance.stop();
2021-11-07 14:58:45 +00:00
});
2021-08-17 13:22:10 +00:00
2019-06-03 20:24:10 +00:00
tap.start();