Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: remove worker isolation options (#20176)

Pavel Feldman3fd053007664
diff --git a/packages/playwright-test/src/configLoader.ts b/packages/playwright-test/src/configLoader.ts
index 6fdff3319d..276b6001f7 100644
--- a/packages/playwright-test/src/configLoader.ts
+++ b/packages/playwright-test/src/configLoader.ts
@@ -483,7 +483,6 @@ export const baseFullConfig: FullConfigInternal = {
_storeDir: '',
_maxConcurrentTestGroups: 0,
_ignoreSnapshots: false,
- _workerIsolation: 'isolate-pools',
_globalScripts: null,
_globalProject: { } as FullProjectInternal,
};
diff --git a/packages/playwright-test/src/dispatcher.ts b/packages/playwright-test/src/dispatcher.ts
index d8fffed935..533ee3b522 100644
--- a/packages/playwright-test/src/dispatcher.ts
+++ b/packages/playwright-test/src/dispatcher.ts
@@ -439,7 +439,7 @@ export class Dispatcher {
}
_createWorker(testGroup: TestGroup, parallelIndex: number, loaderData: SerializedLoaderData) {
- const worker = new WorkerHost(testGroup, parallelIndex, this._configLoader.fullConfig()._workerIsolation, loaderData);
+ const worker = new WorkerHost(testGroup, parallelIndex, loaderData);
const handleOutput = (params: TestOutputPayload) => {
const chunk = chunkFromParams(params);
if (worker.didFail()) {
diff --git a/packages/playwright-test/src/ipc.ts b/packages/playwright-test/src/ipc.ts
index b2fce6f7ff..368b2440a0 100644
--- a/packages/playwright-test/src/ipc.ts
+++ b/packages/playwright-test/src/ipc.ts
@@ -29,11 +29,6 @@ export type TtyParams = {
colorDepth: number;
};
-export type WorkerIsolation =
- 'isolate-projects' | // create new worker for new project type
- 'isolate-pools'; // create new worker for new worker fixture pool digest
-
-
export type ProcessInitParams = {
stdoutParams: TtyParams;
stderrParams: TtyParams;
@@ -41,7 +36,6 @@ export type ProcessInitParams = {
};
export type WorkerInitParams = {
- workerIsolation: WorkerIsolation;
workerIndex: number;
parallelIndex: number;
repeatEachIndex: number;
diff --git a/packages/playwright-test/src/testLoader.ts b/packages/playwright-test/src/testLoader.ts
index 8da1314ecc..d00f56506a 100644
--- a/packages/playwright-test/src/testLoader.ts
+++ b/packages/playwright-test/src/testLoader.ts
@@ -18,7 +18,6 @@ import * as path from 'path';
import { calculateSha1 } from 'playwright-core/lib/utils';
import { FixturePool, isFixtureOption } from './fixtures';
import { setCurrentlyLoadingFileSuite } from './globals';
-import type { WorkerIsolation } from './ipc';
import { Suite, type TestCase } from './test';
import type { TestTypeImpl } from './testType';
import { requireOrImport } from './transform';
@@ -86,7 +85,7 @@ export class TestLoader {
if (!this._projectSuiteBuilders.has(project))
this._projectSuiteBuilders.set(project, new ProjectSuiteBuilder(project));
const builder = this._projectSuiteBuilders.get(project)!;
- return builder.cloneFileSuite(suite, 'isolate-pools', repeatEachIndex, filter);
+ return builder.cloneFileSuite(suite, repeatEachIndex, filter);
}
}
@@ -133,14 +132,14 @@ class ProjectSuiteBuilder {
return this._testPools.get(test)!;
}
- private _cloneEntries(from: Suite, to: Suite, workerIsolation: WorkerIsolation, repeatEachIndex: number, filter: (test: TestCase) => boolean): boolean {
+ private _cloneEntries(from: Suite, to: Suite, repeatEachIndex: number, filter: (test: TestCase) => boolean): boolean {
for (const entry of from._entries) {
if (entry instanceof Suite) {
const suite = entry._clone();
suite._fileId = to._fileId;
to._addSuite(suite);
// Ignore empty titles, similar to Suite.titlePath().
- if (!this._cloneEntries(entry, suite, workerIsolation, repeatEachIndex, filter)) {
+ if (!this._cloneEntries(entry, suite, repeatEachIndex, filter)) {
to._entries.pop();
to.suites.pop();
}
@@ -166,10 +165,7 @@ class ProjectSuiteBuilder {
to.tests.pop();
} else {
const pool = this._buildPool(entry);
- if (this._project._fullConfig._workerIsolation === 'isolate-pools')
- test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
- else
- test._workerHash = `run${this._project._id}-repeat${repeatEachIndex}`;
+ test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
test._pool = pool;
}
}
@@ -179,11 +175,11 @@ class ProjectSuiteBuilder {
return true;
}
- cloneFileSuite(suite: Suite, workerIsolation: WorkerIsolation, repeatEachIndex: number, filter: (test: TestCase) => boolean): Suite | undefined {
+ cloneFileSuite(suite: Suite, repeatEachIndex: number, filter: (test: TestCase) => boolean): Suite | undefined {
const result = suite._clone();
const relativeFile = path.relative(this._project.testDir, suite.location!.file).split(path.sep).join('/');
result._fileId = calculateSha1(relativeFile).slice(0, 20);
- return this._cloneEntries(suite, result, workerIsolation, repeatEachIndex, filter) ? result : undefined;
+ return this._cloneEntries(suite, result, repeatEachIndex, filter) ? result : undefined;
}
private _applyConfigUseOptions(testType: TestTypeImpl, configUse: Fixtures): FixturesWithLocation[] {
diff --git a/packages/playwright-test/src/transform.ts b/packages/playwright-test/src/transform.ts
index cd2d782445..fa97cd353d 100644
--- a/packages/playwright-test/src/transform.ts
+++ b/packages/playwright-test/src/transform.ts
@@ -229,7 +229,7 @@ export async function requireOrImport(file: string) {
}
}
-export function installTransform(): () => void {
+function installTransform(): () => void {
let reverted = false;
const originalResolveFilename = (Module as any)._resolveFilename;
diff --git a/packages/playwright-test/src/types.ts b/packages/playwright-test/src/types.ts
index 1a3e6fba95..edea4f821d 100644
--- a/packages/playwright-test/src/types.ts
+++ b/packages/playwright-test/src/types.ts
@@ -16,7 +16,6 @@
import type { Fixtures, TestInfoError, Project } from '../types/test';
import type { Location, Reporter } from '../types/testReporter';
-import type { WorkerIsolation } from './ipc';
import type { FullConfig as FullConfigPublic, FullProject as FullProjectPublic } from './types';
export * from '../types/test';
export type { Location } from '../types/testReporter';
@@ -48,7 +47,6 @@ export interface FullConfigInternal extends FullConfigPublic {
_storeDir: string;
_maxConcurrentTestGroups: number;
_ignoreSnapshots: boolean;
- _workerIsolation: WorkerIsolation;
/**
* If populated, this should also be the first/only entry in _webServers. Legacy singleton `webServer` as well as those provided via an array in the user-facing playwright.config.{ts,js} will be in `_webServers`. The legacy field (`webServer`) field additionally stores the backwards-compatible singleton `webServer` since it had been showing up in globalSetup to the user.
*/
diff --git a/packages/playwright-test/src/workerHost.ts b/packages/playwright-test/src/workerHost.ts
index c690720905..ccc8756726 100644
--- a/packages/playwright-test/src/workerHost.ts
+++ b/packages/playwright-test/src/workerHost.ts
@@ -15,7 +15,7 @@
*/
import type { TestGroup } from './dispatcher';
-import type { RunPayload, SerializedLoaderData, WorkerInitParams, WorkerIsolation } from './ipc';
+import type { RunPayload, SerializedLoaderData, WorkerInitParams } from './ipc';
import { ProcessHost } from './processHost';
let lastWorkerIndex = 0;
@@ -27,7 +27,7 @@ export class WorkerHost extends ProcessHost<WorkerInitParams> {
currentTestId: string | null = null;
private _params: WorkerInitParams;
- constructor(testGroup: TestGroup, parallelIndex: number, workerIsolation: WorkerIsolation, loader: SerializedLoaderData) {
+ constructor(testGroup: TestGroup, parallelIndex: number, loader: SerializedLoaderData) {
const workerIndex = lastWorkerIndex++;
super(require.resolve('./workerRunner.js'), `worker-${workerIndex}`);
this.workerIndex = workerIndex;
@@ -35,7 +35,6 @@ export class WorkerHost extends ProcessHost<WorkerInitParams> {
this._hash = testGroup.workerHash;
this._params = {
- workerIsolation,
workerIndex: this.workerIndex,
parallelIndex,
repeatEachIndex: testGroup.repeatEachIndex,
diff --git a/packages/playwright-test/src/workerRunner.ts b/packages/playwright-test/src/workerRunner.ts
index 7ab89a5aa2..da029edf35 100644
--- a/packages/playwright-test/src/workerRunner.ts
+++ b/packages/playwright-test/src/workerRunner.ts
@@ -262,14 +262,8 @@ export class WorkerRunner extends ProcessRunner {
}
};
- if (!this._isStopped) {
- // Update the fixture pool - it may differ between tests.
- // - In case of isolate-pools worker isolation, only test-scoped fixtures may differ.
- // - In case of isolate-projects, worker fixtures can differ too, tear down worker fixture scope if they differ.
- if (this._params.workerIsolation === 'isolate-projects' && this._fixtureRunner.pool && this._fixtureRunner.pool.digest !== test._pool!.digest)
- await this._teardownScopes();
+ if (!this._isStopped)
this._fixtureRunner.setPool(test._pool!);
- }
const suites = getSuites(test);
const reversedSuites = suites.slice().reverse();