Repository: microsoft/playwright
File: packages/playwright/src/worker/testInfo.ts (TypeScript)

Code before:
  onStepEnd: () => {},
  onAttach: () => {},
  onTestPaused: () => Promise.reject(new Error('TestInfoImpl not initialized')),
  onCloneStorage: () => Promise.reject(new Error('TestInfoImpl not initialized')),
  onUpstreamStorage: () => Promise.resolve(),
};

export class TestInfoImpl implements TestInfo {
  private _callbacks: TestInfoCallbacks;
  private _snapshotNames: SnapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
  private _ariaSnapshotNames: SnapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
  readonly _timeoutManager: TimeoutManager;
  readonly _startTime: number;
  readonly _startWallTime: number;
  readonly _tracing: TestTracing;
  readonly _uniqueSymbol;

  private _interruptedPromise = new ManualPromise<void>();
  _lastStepId = 0;
  private readonly _requireFile: string;
  readonly _projectInternal: FullProjectInternal;
  readonly _configInternal: FullConfigInternal;
  private readonly _steps: TestStepInternal[] = [];
  private readonly _stepMap = new Map<string, TestStepInternal>();
  _onDidFinishTestFunctionCallback?: () => Promise<void>;
  _onCustomMessageCallback?: (data: any) => Promise<any> = () => Promise.reject(new Error('Only tests that use default Playwright context or page fixture support test_debug'));
  _hasNonRetriableError = false;
  _hasUnhandledError = false;
  _allowSkips = false;

  // ------------ Main methods ------------
  skip: (arg?: any, description?: string) => void;
  fixme: (arg?: any, description?: string) => void;
  fail: (arg?: any, description?: string) => void;
  slow: (arg?: any, description?: string) => void;

  // ------------ TestInfo fields ------------
  readonly testId: string;
  readonly repeatEachIndex: number;
  readonly retry: number;
  readonly workerIndex: number;
  readonly parallelIndex: number;
  readonly project: FullProject;
  readonly config: FullConfig;
  readonly title: string;
  readonly titlePath: string[];
  readonly file: string;
  readonly line: number;
  readonly tags: string[];
  readonly column: number;
  readonly fn: Function;

Review comment (suggestion):
Ideally, this one is set in `index.ts`, because it knows about builtin fixtures. Perhaps in one of our auto-fixtures.

Code after:
  onStepEnd: () => {},
  onAttach: () => {},
  onTestPaused: () => Promise.reject(new Error('TestInfoImpl not initialized')),
  onCloneStorage: () => Promise.reject(new Error('TestInfoImpl not initialized')),
  onUpstreamStorage: () => Promise.resolve(),
};

export class TestInfoImpl implements TestInfo {
  private _callbacks: TestInfoCallbacks;
  private _snapshotNames: SnapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
  private _ariaSnapshotNames: SnapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
  readonly _timeoutManager: TimeoutManager;
  readonly _startTime: number;
  readonly _startWallTime: number;
  readonly _tracing: TestTracing;
  readonly _uniqueSymbol;

  private _interruptedPromise = new ManualPromise<void>();
  _lastStepId = 0;
  private readonly _requireFile: string;
  readonly _projectInternal: FullProjectInternal;
  readonly _configInternal: FullConfigInternal;
  private readonly _steps: TestStepInternal[] = [];
  private readonly _stepMap = new Map<string, TestStepInternal>();
  _onDidFinishTestFunctionCallback?: () => Promise<void>;
  _onCustomMessageCallback?: (data: any) => Promise<any>;
  _hasNonRetriableError = false;
  _hasUnhandledError = false;
  _allowSkips = false;

  // ------------ Main methods ------------
  skip: (arg?: any, description?: string) => void;
  fixme: (arg?: any, description?: string) => void;
  fail: (arg?: any, description?: string) => void;
  slow: (arg?: any, description?: string) => void;

  // ------------ TestInfo fields ------------
  readonly testId: string;
  readonly repeatEachIndex: number;
  readonly retry: number;
  readonly workerIndex: number;
  readonly parallelIndex: number;
  readonly project: FullProject;
  readonly config: FullConfig;
  readonly title: string;
  readonly titlePath: string[];
  readonly file: string;
  readonly line: number;
  readonly tags: string[];
  readonly column: number;
  readonly fn: Function;