Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion integ-tests/dev-server.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runCLI } from '../src/test-utils/index.js';
import { createTelemetryHelper, runCLI } from '../src/test-utils/index.js';
import { type ChildProcess, execSync, spawn } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { mkdir, rm } from 'node:fs/promises';
Expand Down Expand Up @@ -38,6 +38,8 @@ describe('integration: dev server', () => {
let projectPath: string;
let devProcess: ChildProcess | null = null;

const telemetry = createTelemetryHelper();

beforeAll(async () => {
testDir = join(tmpdir(), `agentcore-integ-dev-${randomUUID()}`);
await mkdir(testDir, { recursive: true });
Expand Down Expand Up @@ -81,6 +83,7 @@ describe('integration: dev server', () => {
if (devProcess) {
devProcess.kill('SIGKILL');
}
telemetry.destroy();
await rm(testDir, { recursive: true, force: true });
});

Expand All @@ -101,6 +104,31 @@ describe('integration: dev server', () => {
const serverReady = await waitForServer(port, 20000);
expect(serverReady, 'Dev server should respond to ping within 20s').toBeTruthy();

// Invoke the running server and verify telemetry
const invokeResult = await runCLI(['dev', 'hello', '--port', String(port)], projectPath, {
env: telemetry.env,
});
expect(invokeResult.exitCode).toBe(0);

telemetry.assertMetricEmitted({
command: 'dev',
action: 'invoke',
ui_mode: 'terminal',
exit_reason: 'success',
protocol: 'http',
});

// Verify failure telemetry when invoking a non-running port
telemetry.clearEntries();
const failResult = await runCLI(['dev', 'hello', '--port', '19999'], projectPath, { env: telemetry.env });
expect(failResult.exitCode).toBe(1);

telemetry.assertMetricEmitted({
command: 'dev',
action: 'invoke',
exit_reason: 'failure',
});

// Clean shutdown
devProcess.kill('SIGTERM');
devProcess = null;
Expand Down
Loading
Loading