Skip to content

Commit

Permalink
Fix an showing 1 test when no tests are in the file
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihweiLHBird committed Oct 29, 2024
1 parent 3e993ad commit 60d6a60
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions packages/winglang/src/commands/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async function testOne(

results = await executeTest(synthDir, target, testOptions);
}

// if one of the tests failed, return the results without updating any snapshots.
const success = !results.some((r) => !r.pass);
let snapshot = SnapshotResult.SKIPPED;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 60d6a60

Please sign in to comment.