From 9ea9a5f549027cc96c27630993d66bcdaeb4565a Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Wed, 30 Oct 2024 04:20:15 -0400 Subject: [PATCH] Fix an showing 1 test when no tests are in the file --- packages/winglang/src/commands/test/test.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/packages/winglang/src/commands/test/test.ts b/packages/winglang/src/commands/test/test.ts index 4042cf80e2e..0a12ecacf3c 100644 --- a/packages/winglang/src/commands/test/test.ts +++ b/packages/winglang/src/commands/test/test.ts @@ -262,14 +262,10 @@ export async function renderTestReport( 0 ); - // if there are no inflight tests, add a dummy "pass" result + // return early if there are no tests, return a pass output // to indicate that compilation and preflight checks passed if (results.length === 0) { - results.push({ - pass: true, - path: "", - traces: [], - }); + return `${chalk.green("pass")} ─ ${basename(entrypoint)} ${chalk.gray("(no tests)")}`; } for (const result of results.sort(sortTests)) { @@ -307,13 +303,8 @@ export async function renderTestReport( } firstRow.push(basename(entrypoint)); - - if (result.path?.length > 0) { - firstRow.push(chalk.gray("»")); - firstRow.push(chalk.whiteBright(result.path.padEnd(longestPath))); - } else { - firstRow.push(chalk.gray("(no tests)")); - } + firstRow.push(chalk.gray("»")); + firstRow.push(chalk.whiteBright(result.path.padEnd(longestPath))); // okay we are ready to print the test result