Catalog
vercel/capture-api-response-test-fixture

vercel

capture-api-response-test-fixture

Capture API response test fixture.

NewUpdated Sep 9, 2026

API Response Test Fixtures

For provider response parsing tests, we aim at storing test fixtures with the true responses from the providers (unless they are too large in which case some cutting that does not change semantics is advised).

The fixtures are stored in a __fixtures__ subfolder, e.g. packages/openai/src/responses/__fixtures__. See the file names in packages/openai/src/responses/__fixtures__ for naming conventions and packages/openai/src/responses/openai-responses-language-model.test.ts for how to set up test helpers.

You can use our examples under /examples/ai-functions to generate test fixtures.

generateText (doGenerate testing)

For generateText, put the script under src/generate-text/<provider>/, log the raw response output to the console, and copy it into a new test fixture.

import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { run } from '../../lib/run';

run(async () => {
  const result = await generateText({
    model: openai('gpt-5-nano'),
    prompt: 'Invent a new holiday and describe its traditions.',
  });

  console.log(JSON.stringify(result.response.body, null, 2));
});

streamText (doStream testing)

For streamText, you need to set includeRawChunks to true and use the special saveRawChunks helper. Put the script under the provider directory and run it from the /examples/ai-functions folder via pnpm tsx src/stream-text/<provider>/<script-name>.ts. The result is then stored in the /examples/ai-functions/output folder. You can copy it to your fixtures folder and rename it.

import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { run } from '../../lib/run';
import { saveRawChunks } from '../../lib/save-raw-chunks';

run(async () => {
  const result = streamText({
    model: openai('gpt-5-nano'),
    prompt: 'Invent a new holiday and describe its traditions.',
    includeRawChunks: true,
  });

  await saveRawChunks({ result, filename: 'openai-gpt-5-nano' });
});
Files1
1 files · 552 B

Select a file to preview

Overall Score

82/100

Grade

B

Good

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

88

Quality

82

Clarity

85

Completeness

75

Summary

This skill guides developers on capturing and storing API response test fixtures for testing provider response parsing logic. It documents conventions for fixture organization, naming, and provides code examples for generating fixtures from `generateText` and `streamText` function calls.

Detected Capabilities

code generationfile writelogging to consoleproject filesystem navigation

Trigger Keywords

Phrases that agents use to match this skill to user intent.

capture api responsetest fixture generationstreaming response fixturegeneratetext fixtureapi mock dataresponse parsing tests

Referenced Domains

External domains referenced in skill content, detected by static analysis.

www.apache.org

Use Cases

  • Generate test fixtures from live generateText API calls and store them in __fixtures__ directories
  • Capture streaming responses with raw chunks using streamText and saveRawChunks helper
  • Set up test fixture helpers following project naming and organizational conventions
  • Document API responses for regression testing and provider integration validation

Quality Notes

  • Clear, well-structured guidance with practical code examples for both generateText and streamText patterns
  • Documentation references existing project conventions (fixture naming, file locations) which reduces ambiguity
  • Provides working TypeScript examples that developers can directly adapt to their use case
  • References existing test files (openai-responses-language-model.test.ts) as additional learning resources
  • Includes helper functions (saveRawChunks) documented but not shown in full detail — may benefit from linked documentation
  • Scope is tightly focused on test fixture capture within the ai-sdk ecosystem
Model: claude-haiku-4-5-20251001Analyzed: Sep 9, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

  1. v1.1

    Content updated

    ✦ AIRestructures test fixture script directory layout: generateText scripts move to src/generate-text/<provider>/, streamText scripts to src/stream-text/<provider>/, and updates import paths accordingly.

    2026-09-09

    LATEST
  2. v1.0

    2026-05-02

    View This VersionInitial version

Use vercel/capture-api-response-test-fixture in your dev environment

Command Palette

Search for a command to run...