or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

Fixture-Backed HTTP Runner

Helper utilities to wrap integration HTTP calls with fixture record/replay modes so tests can run without live network access.

Capabilities

Record fixtures on demand

  • Running runWithFixtures('record', 'profile', requestFn) executes requestFn, allows real HTTP, and writes a fixture file fixtures/profile.json capturing each request/response so subsequent runs can replay without network. @test

Lockdown replay using fixtures

  • With an existing fixtures/profile.json file, runWithFixtures('lockdown', ...) replays responses from the fixture and throws if requestFn triggers a request not represented in the fixture. @test

Update existing fixtures

  • When mode is update, the helper overwrites fixtures/profile.json with a fresh recording of the current HTTP interactions from requestFn. @test

Wild runs bypass fixtures

  • When mode is wild, runWithFixtures bypasses fixture loading/recording and lets requestFn hit the network directly without creating or using fixture files. @test

Implementation

@generates

API

export async function runWithFixtures(mode, fixtureName, requestFn, options);
/**
 * @param {'record'|'lockdown'|'update'|'wild'} mode
 * @param {string} fixtureName Base name for the fixture file stored under `fixtures/`.
 * @param {() => Promise<any>} requestFn Executes HTTP requests that should be recorded or replayed.
 * @param {{
 *   fixtureDir?: string,
 *   before?: (ctx: { fixturePath: string }) => Promise<void> | void,
 *   after?: (ctx: { fixturePath: string, recordings?: unknown[] }) => Promise<void> | void
 * }} [options]
 * @returns {Promise<{ result: any, fixturePath: string }>}
 */

Dependencies { .dependencies }

nock { .dependency }

HTTP mocking library with fixture record/replay support.