Skip to content

Commit 89903bb

Browse files
committed
Suppress non-test output
1 parent 5e8d5dd commit 89903bb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

tests/scripts/generate-test-reports.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import * as fs from "fs";
1414
import * as path from "path";
1515
import { fileURLToPath } from "url";
16-
import { run } from "../utils/agent-runner";
16+
import { run, TestConfig } from "../utils/agent-runner";
1717

1818
const __filename = fileURLToPath(import.meta.url);
1919
const __dirname = path.dirname(__filename);
@@ -46,7 +46,7 @@ async function processMarkdownFile(mdPath: string, reportTemplate: string): Prom
4646
console.log(` Processing: ${fileName}...`);
4747

4848
// Use agent runner to generate report
49-
const config = {
49+
const config: TestConfig = {
5050
prompt: `You are a test report generator. Your job is to read test data and output a formatted markdown report.
5151
5252
CRITICAL: Output ONLY the markdown report itself. Do NOT include any preamble, explanations, or meta-commentary about what you're doing.

tests/utils/agent-runner.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ function generateMarkdownReport(config: TestConfig, agentMetadata: AgentMetadata
222222
* Write markdown report to file
223223
*/
224224
function writeMarkdownReport(config: TestConfig, agentMetadata: AgentMetadata): void {
225+
if (!isTest()) {
226+
return;
227+
}
228+
225229
try {
226230
const filePath = buildShareFilePath();
227231
const dir = path.dirname(filePath);
@@ -265,7 +269,7 @@ export async function run(config: TestConfig): Promise<AgentMetadata> {
265269

266270
// Copilot client with yolo mode
267271
const cliArgs: string[] = config.nonInteractive ? ["--yolo"] : [];
268-
if (process.env.DEBUG) {
272+
if (process.env.DEBUG && isTest()) {
269273
cliArgs.push("--log-dir");
270274
cliArgs.push(buildLogFilePath());
271275
}
@@ -548,6 +552,16 @@ export function buildLogFilePath(): string {
548552
return path.join(DEFAULT_REPORT_DIR, `test-run-${TIME_STAMP}`, getTestName());
549553
}
550554

555+
function isTest(): boolean {
556+
try {
557+
// Jest provides expect.getState() with current test info
558+
const _state = expect.getState();
559+
return true;
560+
} catch {
561+
return false;
562+
}
563+
}
564+
551565
function getTestName(): string {
552566
try {
553567
// Jest provides expect.getState() with current test info

0 commit comments

Comments
 (0)