Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright LocalUtils

From Leeroopedia
Revision as of 11:37, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_LocalUtils.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Implementation Page

Overview

LocalUtils provides server-side utility functions for trace file management, HAR operations, and zip file creation used by the Playwright test runner and trace viewer.

Description

This module exports utility functions that operate on the local filesystem for:

  • Zip creation -- packages trace files, source code, and call stack metadata into zip archives for trace storage
  • HAR management -- interfaces with HarBackend for HTTP Archive operations
  • Stack session tracking -- manages call stack metadata across test sessions for inclusion in trace files

The StackSession type tracks per-file trace writers and their associated call stack data, supporting both live and completed sessions.

Usage

Used internally by the Playwright test runner to create trace zip files and manage HAR recordings.

Code Reference

Source Location

packages/playwright-core/src/server/localUtils.ts (216 lines)

Function Signatures

export async function zip(
  progress: Progress,
  stackSessions: Map<string, StackSession>,
  params: channels.LocalUtilsZipParams
): Promise<void>

export type StackSession = {
  file: string;
  writer: Promise<void>;
  tmpDir: string | undefined;
  callStacks: channels.ClientSideCallMetadata[];
  live?: boolean;
};

Import

import { zip } from './server/localUtils';
import type { StackSession } from './server/localUtils';

I/O Contract

Inputs

  • progress: Progress -- progress reporting interface
  • stackSessions: Map -- map of session file paths to stack session data
  • params: LocalUtilsZipParams -- zip parameters including file entries

Outputs

  • Creates a zip file on disk containing trace data, source files, and call stack metadata
  • Resolves the returned promise when zip creation is complete

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment