mcp-server-tester-sse-http-stdio
Version:
MCP Server Tester with SSE support - Test MCP servers using HTTP, SSE, and STDIO transports
80 lines (79 loc) • 2.36 kB
JavaScript
/**
* Central display manager that coordinates test output formatting
*/
import { ConsoleFormatter } from './formatters/ConsoleFormatter.js';
import { JunitXmlFormatter } from './formatters/JunitXmlFormatter.js';
export class DisplayManager {
formatters;
constructor(options = {}) {
this.formatters = [];
// Always include console formatter
this.formatters.push(new ConsoleFormatter(options));
// Add JUnit XML formatter if requested
if (options.junitXml !== undefined) {
const filename = options.junitXml || 'junit.xml';
this.formatters.push(new JunitXmlFormatter(options, filename));
}
}
/**
* Emit a test event to all active formatters
*/
emit(event) {
this.formatters.forEach(formatter => formatter.onEvent(event));
}
/**
* Convenience methods for common events
*/
suiteStart(testCount, modelCount) {
this.emit({
type: 'suite_start',
data: {
testCount,
modelCount,
totalRuns: modelCount ? testCount * modelCount : testCount,
},
});
}
progress(message, model) {
this.emit({
type: 'progress',
data: { message, model },
});
}
testStart(name, model) {
this.emit({
type: 'test_start',
data: { name, model },
});
}
testComplete(name, passed, errors, model, prompt, messages, scorer_results) {
this.emit({
type: 'test_complete',
data: { name, model, passed, errors, prompt, messages, scorer_results },
});
}
suiteComplete(total, passed, failed, duration) {
this.emit({
type: 'suite_complete',
data: { total, passed, failed, duration },
});
}
toolDiscovery(expectedTools, foundTools, passed) {
this.emit({
type: 'tool_discovery',
data: { expectedTools, foundTools, passed },
});
}
sectionStart(section, title) {
this.emit({
type: 'section_start',
data: { section, title },
});
}
/**
* Flush any pending output from all formatters
*/
flush() {
this.formatters.forEach(formatter => formatter.flush());
}
}