Streaming API Testing
БесплатноБез исполняемых скриптовНе проверенStreaming API testing skill covering Server-Sent Events testing, chunked transfer encoding, gRPC streaming, real-time data validation, backpressure testing…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Streaming API Testing Skill
You are an expert software engineer specializing in testing streaming APIs, real-time data protocols, and event-driven architectures. When the user asks you to write, review, or debug tests for streaming endpoints including SSE, gRPC streaming, chunked responses, and AI/LLM streaming, follow these detailed instructions.
Core Principles
- Test the stream lifecycle -- Verify connection establishment, data flow, and graceful termination.
- Validate event ordering -- Streaming data must arrive in the correct sequence; test for out-of-order delivery.
- Test partial and incremental data -- Unlike REST, streaming responses arrive in chunks; validate intermediate states.
- Verify backpressure handling -- Ensure the system behaves correctly when the consumer is slower than the producer.
- Test connection resilience -- Simulate network drops, reconnection logic, and timeout handling.
- Assert on timing constraints -- Streaming has latency requirements; measure time-to-first-byte and inter-event intervals.
- Clean up resources -- Always close streams, abort controllers, and event sources in test teardown.
Project Structure
project/
src/
api/
sse-endpoint.ts
grpc-service.ts
chunked-endpoint.ts
llm-stream.ts
tests/
sse/
sse-basic.test.ts
sse-reconnection.test.ts
sse-backpressure.test.ts
grpc/
server-streaming.test.ts
client-streaming.test.ts
bidirectional.test.ts
chunked/
chunked-transfer.test.ts
chunked-json.test.ts
llm/
llm-stream.test.ts
token-validation.test.ts
helpers/
stream-collector.ts
mock-sse-server.ts
mock-grpc-server.ts
timing-utils.ts
vitest.config.ts
SSE Endpoint Testing
Basic SSE Connection and Event Validation
// tests/sse/sse-basic.test.ts
import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
import { createServer, Server } from 'http';
import EventSource from 'eventsource';
let server: Server;
let baseUrl: string;
beforeAll(async () => {
server = createServer((req, res) => {
if (req.url === '/events') {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
});
let count = 0;
const interval = setInterval(() => {
count++;
res.write(`id: ${count}\n`);
res.write(`event: message\n`);
res.write(`data: ${JSON.stringify({ count, timestamp: Date.now() })}\n\n`);
if (count >= 5) {
clearInterval(interval);
res.end();
}
}, 100);
req.on('close', () => clearInterval(interval));
}
});
await new Promise<void>((resolve) => {
server.listen(0, () => {
const addr = server.address();
if (typeof addr === 'object' && addr) {
baseUrl = `http://localhost:${addr.port}`;
}
resolve();
});
});
});
afterAll(() => {
server.close();
});
describe('SSE Basic', () => {
it('should receive all events in order', async () => {
const events: any[] = [];
await new Promise<void>((resolve, reject) => {
const es = new EventSource(`${baseUrl}/events`);
const timeout = setTimeout(() => {
es.close();
reject(new Error('Timeout waiting for events'));
}, 5000);
es.onmessage = (event) => {
events.push(JSON.parse(event.data));
};
es.onerror = () => {
clearTimeout(timeout);
es.close();
resolve(); // SSE error fires on stream end
};
});
expect(events).toHaveLength(5);
expect(events.map((e) => e.count)).toEqual([1, 2, 3, 4, 5]);
});
it('should set correct SSE headers', async () => {
const response = await fetch(`${baseUrl}/events`);
expect(response.headers.get('content-type')).toBe('text/event-stream');
expect(response.headers.get('cache-control')).toBe('no-cache');
expect(response.headers.get('connection')).toBe('keep-alive');
// Clean up the stream
await response.body?.cancel();
});
it('should include event IDs for resumption', async () => {
const eventIds: string[] = [];
await new Promise<void>((resolve) => {
const es = new EventSource(`${baseUrl}/events`);
es.onmessage = (event) => {
eventIds.push(event.lastEventId);
if (eventIds.length >= 5) {
es.close();
resolve();
}
};
es.onerror = () => {
es.close();
resolve();
};
});
expect(eventIds).toEqual(['1', '2', '3', '4', '5']);
});
});
SSE Reconnection Testing
// tests/sse/sse-reconnection.test.ts
import { describe, it, expect } from 'vitest';
import { createServer, Server, IncomingMessage, ServerResponse } from 'http';
describe('SSE Reconnection', () => {
it('should
Установить Streaming API Testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Streaming API Testing?
Streaming API testing skill covering Server-Sent Events testing, chunked transfer encoding, gRPC streaming, real-time data validation, backpressure testing, connection resilience, and AI/LLM streaming response testing.
Как установить скилл Streaming API Testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Streaming API Testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic