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
16 changes: 2 additions & 14 deletions test/aspire-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { trace, metrics } from '@opentelemetry/api';
import { NodeSDK, resources, metrics as sdkMetrics } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';
import { dockerSkipReason } from './helpers/skip-guards.js';

const { Resource } = resources;
const { PeriodicExportingMetricReader } = sdkMetrics;
Expand All @@ -23,20 +24,7 @@ const { PeriodicExportingMetricReader } = sdkMetrics;
// Skip guard — bail early if Docker is unavailable or tests disabled
// ============================================================================

function dockerAvailable(): boolean {
try {
execSync('docker --version', { stdio: 'ignore' });
return true;
} catch {
return false;
}
}

const SKIP_REASON = process.env['SKIP_DOCKER_TESTS'] === '1'
? 'SKIP_DOCKER_TESTS=1'
: !dockerAvailable()
? 'Docker not available'
: null;
const SKIP_REASON = dockerSkipReason();

const CONTAINER_NAME = 'squad-aspire-dashboard';
const DASHBOARD_URL = 'http://localhost:18888';
Expand Down
36 changes: 36 additions & 0 deletions test/helpers/skip-guards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Shared test helpers for skip guards and environment detection.
*
* Provides reusable functions for detecting Docker availability,
* shell module availability, and other environment conditions
* that determine whether certain test suites should run.
Comment on lines +2 to +6
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file header comment claims this helper also covers “shell module availability” and other conditions, but this module currently only implements Docker helpers. This makes the comment misleading—either remove that claim or add the corresponding helper(s).

Suggested change
* Shared test helpers for skip guards and environment detection.
*
* Provides reusable functions for detecting Docker availability,
* shell module availability, and other environment conditions
* that determine whether certain test suites should run.
* Shared test helpers for Docker-related skip guards and environment detection.
*
* Provides reusable functions for detecting Docker availability
* and determining whether Docker-dependent test suites should run.

Copilot uses AI. Check for mistakes.
*/

import { execSync } from 'node:child_process';

/**
* Check if Docker is available on this machine.
* Returns true if `docker --version` succeeds within 5 seconds.
*/
export function isDockerAvailable(): boolean {
try {
execSync('docker --version', { stdio: 'ignore', timeout: 5000 });
return true;
} catch {
return false;
}
Comment on lines +12 to +21
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDockerAvailable() currently treats docker --version as proof Docker is “available”, but that succeeds even when the Docker daemon isn’t running (common cause of the reported failures). To make the skip guard actually prevent Docker API connection errors, check daemon connectivity instead (e.g., docker info / docker ps with a short timeout) and return false when the server isn’t reachable.

Copilot uses AI. Check for mistakes.
}

/**
* Determine skip reason for Docker-dependent tests.
* Returns null if tests should run, or a string reason to skip.
*/
export function dockerSkipReason(): string | null {
if (process.env['SKIP_DOCKER_TESTS'] === '1') {
return 'SKIP_DOCKER_TESTS=1';
}
if (!isDockerAvailable()) {
return 'Docker not available';
}
return null;
}
2 changes: 1 addition & 1 deletion test/template-sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('sync-templates.mjs script execution', () => {
const output = execSync('node scripts/sync-templates.mjs', {
cwd: ROOT,
encoding: 'utf-8',
timeout: 30_000,
timeout: 60_000,
});
expect(output).toContain('Synced');
});
Expand Down
Loading