Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browser-pool",
"version": "2.0.2",
"version": "2.0.3",
"description": "Rotate multiple browsers using popular automation libraries such as Playwright or Puppeteer.",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -41,7 +41,6 @@
},
"dependencies": {
"@apify/log": "^1.1.1",
"fs-extra": "^10.0.0",
"lodash.merge": "^4.6.2",
"nanoid": "^3.1.25",
"ow": "^0.27.0",
Expand All @@ -60,6 +59,7 @@
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"eslint": "^7.32.0",
"fs-extra": "^10.0.0",
"gen-esm-wrapper": "^1.1.2",
"jest": "^27.0.6",
"jest-circus": "^27.0.6",
Expand Down
7 changes: 1 addition & 6 deletions src/abstract-classes/browser-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import merge from 'lodash.merge';
import { ensureDir } from 'fs-extra';
import { log } from '../logger';
import { LaunchContext, LaunchContextOptions } from '../launch-context';
import { BrowserController } from './browser-controller';
Expand Down Expand Up @@ -143,16 +142,12 @@ export abstract class BrowserPlugin<
async launch(
launchContext: LaunchContext<Library, LibraryOptions, LaunchResult, NewPageOptions, NewPageResult> = this.createLaunchContext(),
): Promise<LaunchResult> {
const { proxyUrl, useIncognitoPages, userDataDir } = launchContext;
const { proxyUrl } = launchContext;

if (proxyUrl) {
await this._addProxyToLaunchOptions(launchContext);
}

if (!useIncognitoPages) {
await ensureDir(userDataDir);
}

return this._launch(launchContext);
}

Expand Down
5 changes: 1 addition & 4 deletions src/launch-context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { join } from 'path';
import { tmpdir } from 'os';
import { nanoid } from 'nanoid';
import type { BrowserPlugin, CommonBrowser, CommonLibrary } from './abstract-classes/browser-plugin';
import { UnwrapPromise } from './utils';

Expand Down Expand Up @@ -77,7 +74,7 @@ export class LaunchContext<
launchOptions,
proxyUrl,
useIncognitoPages,
userDataDir = join(tmpdir(), nanoid()),
userDataDir = '',
} = options;

this.id = id;
Expand Down
13 changes: 0 additions & 13 deletions test/browser-plugins/plugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import puppeteer from 'puppeteer';
import playwright from 'playwright';
import fs from 'fs';

import { PuppeteerPlugin } from '../../src/puppeteer/puppeteer-plugin';
import { PuppeteerController } from '../../src/puppeteer/puppeteer-controller';
Expand Down Expand Up @@ -76,18 +75,6 @@ const runPluginTest = <
expect(context.useIncognitoPages).toEqual(desiredObject.useIncognitoPages);
});

test('should create userDatadir', async () => {
plugin = new Plugin(library as never, {
useIncognitoPages: false,
});

const context = plugin.createLaunchContext();
browser = await plugin.launch(context as never);

expect(fs.existsSync(context.userDataDir)).toBeTruthy();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we remove this line, shouldn't we remove the whole test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

await browser.close();
});

test('should get default launchContext values from plugin options', async () => {
const proxyUrl = 'http://apify1234@10.10.10.0:8080/';

Expand Down