or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

Traffic Recording Replay Helper

Build a small utility that captures real HTTP traffic to fixture files and replays those fixtures in later runs. The utility should avoid exposing the underlying interception library and provide a clear lifecycle for recording and playback.

Capabilities

Record sessions

  • Starting recording captures outgoing requests and responses (method, path, status, body) for a target host and saves them as a JSON array in the given fixture file without printing to stdout. @test
  • When header capture is enabled, request headers are preserved inside each recorded definition. @test

Replay fixtures

  • Loading a fixture file replays the recorded responses for matching requests without hitting the real network, using only the definitions from that file. @test
  • An option allows unmatched requests to pass through to the real network while still replaying recorded ones. @test

Reset lifecycle

  • Clearing playback removes all interceptors and restores normal network behavior for subsequent tests. @test

Implementation

@generates

API

export interface RecordingOptions {
  outputFile: string;
  includeHeaders?: boolean;
}

export interface PlaybackOptions {
  allowUnmocked?: boolean;
}

export function startRecording(options: RecordingOptions): Promise<void>;
export function stopRecording(): Promise<unknown[]>;
export function usePlayback(fixturePath: string, options?: PlaybackOptions): Promise<void>;
export function resetPlayback(): void;

Dependencies { .dependencies }

nock { .dependency }

Provides HTTP interception, recording, and fixture replay.