diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.ts index b7b958d262..07087f030d 100644 --- a/packages/playwright/src/common/config.ts +++ b/packages/playwright/src/common/config.ts @@ -24,7 +24,6 @@ import { getPackageJsonPath, mergeObjects } from '../util'; import type { Matcher } from '../util'; import type { ConfigCLIOverrides } from './ipc'; import type { FullConfig, FullProject } from '../../types/testReporter'; -import { LastRunReporter } from '../runner/lastRun'; export type ConfigLocation = { resolvedConfigFile?: string; @@ -59,7 +58,6 @@ export class FullConfigInternal { defineConfigWasUsed = false; shardingMode: ShardingMode; lastRunFile: string | undefined; - readonly lastRunReporter: LastRunReporter; constructor(location: ConfigLocation, userConfig: Config, configCLIOverrides: ConfigCLIOverrides) { if (configCLIOverrides.projects && userConfig.projects) @@ -135,8 +133,6 @@ export class FullConfigInternal { resolveProjectDependencies(this.projects); this._assignUniqueProjectIds(this.projects); this.config.projects = this.projects.map(p => p.project); - - this.lastRunReporter = new LastRunReporter(this); } private _assignUniqueProjectIds(projects: FullProjectInternal[]) { diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.ts index dad63be820..91e8d0fe0a 100644 --- a/packages/playwright/src/reporters/merge.ts +++ b/packages/playwright/src/reporters/merge.ts @@ -28,6 +28,7 @@ import { currentBlobReportVersion, type BlobReportMetadata } from './blob'; import { relativeFilePath } from '../util'; import type { TestError } from '../../types/testReporter'; import type * as blobV1 from './versions/blobV1'; +import { LastRunReporter } from '../runner/lastRun'; type StatusCallback = (message: string) => void; @@ -39,7 +40,8 @@ type ReportData = { export async function createMergedReport(config: FullConfigInternal, dir: string, reporterDescriptions: ReporterDescription[], rootDirOverride: string | undefined) { const reporters = await createReporters(config, 'merge', false, reporterDescriptions); - const multiplexer = new Multiplexer([...reporters, config.lastRunReporter]); + const lastRun = new LastRunReporter(config); + const multiplexer = new Multiplexer([...reporters, lastRun]); const stringPool = new StringInternPool(); let printStatus: StatusCallback = () => {}; diff --git a/packages/playwright/src/runner/runner.ts b/packages/playwright/src/runner/runner.ts index 712485f724..22f8204592 100644 --- a/packages/playwright/src/runner/runner.ts +++ b/packages/playwright/src/runner/runner.ts @@ -24,6 +24,7 @@ import { TestRun, createTaskRunner, createTaskRunnerForClearCache, createTaskRun import type { FullConfigInternal } from '../common/config'; import { affectedTestFiles } from '../transform/compilationCache'; import { InternalReporter } from '../reporters/internalReporter'; +import { LastRunReporter } from './lastRun'; type ProjectConfigWithFiles = { name: string; @@ -74,10 +75,11 @@ export class Runner { webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p })); const reporters = await createReporters(config, listOnly ? 'list' : 'test', false); + const lastRun = new LastRunReporter(config); if (config.cliLastFailed) - await config.lastRunReporter.filterLastFailed(); + await lastRun.filterLastFailed(); - const reporter = new InternalReporter([...reporters, config.lastRunReporter]); + const reporter = new InternalReporter([...reporters, lastRun]); const taskRunner = listOnly ? createTaskRunnerForList( config, reporter, diff --git a/packages/playwright/src/runner/testGroups.ts b/packages/playwright/src/runner/testGroups.ts index 4f4abf1580..4673adc659 100644 --- a/packages/playwright/src/runner/testGroups.ts +++ b/packages/playwright/src/runner/testGroups.ts @@ -16,7 +16,7 @@ import type { FullConfigInternal } from '../common/config'; import type { Suite, TestCase } from '../common/test'; -import type { LastRunInfo } from './lastRun'; +import { LastRunReporter, type LastRunInfo } from './lastRun'; export type TestGroup = { workerHash: string; @@ -144,7 +144,8 @@ export async function filterForShard(config: FullConfigInternal, testGroups: Tes if (mode === 'round-robin') return filterForShardRoundRobin(shard, testGroups); if (mode === 'duration-round-robin') { - const lastRunInfo = await config.lastRunReporter.lastRunInfo(); + const lastRun = new LastRunReporter(config); + const lastRunInfo = await lastRun.lastRunInfo(); return filterForShardRoundRobin(shard, testGroups, lastRunInfo); } return filterForShardPartition(shard, testGroups);