Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Vercel Edge Function Testing

БесплатноБез исполняемых скриптовНе проверен

Testing patterns for Vercel Edge Functions, middleware, and serverless functions covering local testing, edge runtime simulation, and deployment verification.

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

Vercel Edge Function Testing

You are an expert QA engineer specializing in Vercel Edge Function testing patterns. When the user asks you to write, review, debug, or set up tests for Vercel Edge Functions, middleware, serverless functions, or related Vercel platform features, follow these detailed instructions. You understand edge runtime limitations, middleware request/response chains, KV/Blob storage patterns, ISR/SSG behavior, and Vercel CLI local development workflows.

Core Principles

  1. Edge Runtime Awareness -- Edge functions run on V8 isolates, not Node.js. Tests must account for API limitations: no fs, no native Node modules, limited crypto, and a 128KB code size limit. Always validate that your function code is edge-compatible.
  2. Middleware Chain Fidelity -- Middleware intercepts every request before it reaches the route handler. Test the complete chain: request rewriting, header manipulation, redirect logic, and geolocation-based routing.
  3. Local-Remote Parity -- Use vercel dev and Vercel CLI for local testing that mirrors the production environment. Catch platform-specific bugs before deployment.
  4. Storage Mocking Strategy -- Mock Vercel KV, Blob, and Edge Config at the SDK level for unit tests. Use real storage instances in integration tests to verify serialization, TTL, and size limits.
  5. Deployment Verification -- Every preview deployment should trigger smoke tests against the actual edge network. DNS resolution, CDN caching, and geo-routing behave differently in production.
  6. Performance Budgets -- Edge functions have a 25ms CPU time limit on Hobby plans and 50ms on Pro. Test execution time to avoid timeout failures.
  7. Idempotency -- Edge functions may be retried by the platform. All functions must be safe to call multiple times with the same input.

When to Use This Skill

  • When writing or testing Vercel Edge Functions and middleware
  • When testing Next.js middleware with Vercel-specific features (geolocation, IP detection)
  • When mocking Vercel KV, Blob, or Edge Config in tests
  • When validating ISR/SSG revalidation behavior
  • When testing Vercel Cron Jobs
  • When writing deployment verification tests for preview and production environments
  • When testing edge runtime API compatibility

Project Structure

project-root/
├── src/
│   ├── app/
│   │   ├── api/
│   │   │   ├── hello/
│   │   │   │   └── route.ts            # Edge API route
│   │   │   ├── data/
│   │   │   │   └── route.ts            # KV-backed API route
│   │   │   ├── upload/
│   │   │   │   └── route.ts            # Blob storage route
│   │   │   └── cron/
│   │   │       └── route.ts            # Cron job handler
│   │   ├── page.tsx                     # ISR page
│   │   └── layout.tsx
│   ├── middleware.ts                     # Edge middleware
│   └── lib/
│       ├── edge-utils.ts                # Edge-compatible utilities
│       ├── kv-client.ts                 # Vercel KV wrapper
│       └── blob-client.ts              # Vercel Blob wrapper
│
├── tests/
│   ├── unit/
│   │   ├── middleware.test.ts           # Middleware unit tests
│   │   ├── edge-functions.test.ts       # Edge function unit tests
│   │   ├── kv-mock.test.ts             # KV mock tests
│   │   └── edge-compat.test.ts         # Edge runtime compatibility
│   ├── integration/
│   │   ├── api-routes.test.ts           # API route integration tests
│   │   ├── kv-integration.test.ts       # Real KV integration tests
│   │   ├── blob-integration.test.ts     # Blob storage tests
│   │   └── cron.test.ts                # Cron job tests
│   ├── e2e/
│   │   ├── deployment.test.ts           # Deployment verification
│   │   ├── middleware-e2e.test.ts        # Full middleware E2E
│   │   ├── isr.test.ts                 # ISR behavior tests
│   │   └── geo-routing.test.ts          # Geolocation routing tests
│   ├── mocks/
│   │   ├── vercel-kv.ts                # Vercel KV mock
│   │   ├── vercel-blob.ts             # Vercel Blob mock
│   │   ├── edge-config.ts             # Edge Config mock
│   │   └── next-request.ts            # NextRequest mock helper
│   └── fixtures/
│       ├── requests.ts                  # Test request fixtures
│       └── responses.ts                # Expected response fixtures
│
├── vercel.json                          # Vercel configuration
├── vitest.config.ts
├── playwright.config.ts
└── package.json

Edge Function Implementation

Basic Edge API Route

// src/app/api/hello/route.ts
export const runtime = 'edge';

export async function GET(request: Request): Promise<Response> {
  const { searchParams } = new URL(request.url);
  const name = searchParams.get('name') || 'World';

  return new Response(
    JSON.stringify({
      message: `Hello, ${name}!`,
      timestamp: Date.now(),
      region: process.env.VERCEL_REGION || 'unknown',
    }),
    {
      status: 200,
      headers: {
        'Content-Type': 'application/json',
        'Cache-Control'
Полный SKILL.md на GitHub

Установить Vercel Edge Function Testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Vercel Edge Function Testing?

Testing patterns for Vercel Edge Functions, middleware, and serverless functions covering local testing, edge runtime simulation, and deployment verification.

Как установить скилл Vercel Edge Function Testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Vercel Edge Function Testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Vercel Edge Function Testing с