From df005e33b892dfe923093d2b17a99bcfa3978fe4 Mon Sep 17 00:00:00 2001 From: Shafikul Islam Tanbir <58387559+shafiktanbir@users.noreply.github.com> Date: Sun, 22 Nov 2026 23:37:44 +0600 Subject: [PATCH 1/2] fix(cli): keep Link column aligned on runError rows in GitHub reporter --- .../github-md-builder.spec.ts.snap | 2 +- .../__tests__/github-md-builder.spec.ts | 51 +++++++++++++++++++ packages/cli/src/reporters/github.ts | 7 ++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/reporters/__tests__/__snapshots__/github-md-builder.spec.ts.snap b/packages/cli/src/reporters/__tests__/__snapshots__/github-md-builder.spec.ts.snap index c1448e640..5152f1898 100644 --- a/packages/cli/src/reporters/__tests__/__snapshots__/github-md-builder.spec.ts.snap +++ b/packages/cli/src/reporters/__tests__/__snapshots__/github-md-builder.spec.ts.snap @@ -27,7 +27,7 @@ Ran **1** checks in **eu-west-1**. [View detailed test session summary](https://app.checklyhq.com/accounts/test-account-123/test-sessions/0c4c64b3-79c5-44a6-ae07-b580ce73f328) |Result|Name|Check Type|Filename|Duration|Link| |:-|:-|:-|:-|:-|:-| -|❌ Fail|Timed out check|-|\`folder/timeout.check.ts\`|- | +|❌ Fail|Timed out check|-|\`folder/timeout.check.ts\`|- || ## Execution Errors diff --git a/packages/cli/src/reporters/__tests__/github-md-builder.spec.ts b/packages/cli/src/reporters/__tests__/github-md-builder.spec.ts index 758bb8485..022bc016e 100644 --- a/packages/cli/src/reporters/__tests__/github-md-builder.spec.ts +++ b/packages/cli/src/reporters/__tests__/github-md-builder.spec.ts @@ -65,6 +65,12 @@ describe('GithubMdBuilder', () => { expect(markdown).not.toContain('NaN') expect(markdown).toContain('## Execution Errors') expect(markdown).toContain(runError) + + const tableLines = markdown.split('\n').filter(line => line.startsWith('|')) + // 6 columns (including Link) -> 7 delimiters per line + for (const line of tableLines) { + expect(line.match(/(? { const row = (name: string, timedOut: boolean) => [`seq-${name}`, { @@ -199,4 +205,49 @@ describe('GithubMdBuilder', () => { expect(line.match(/(? { + const map: checkFilesMap = new Map([ + ['folder/api.check.ts', new Map([ + ['seq-with-file', { + result: { + name: 'File Check', + sourceFile: 'folder/api.check.ts', + checkType: 'API', + responseTime: 10, + } as any, + titleString: 'File Check', + numRetries: 0, + }], + ])], + [undefined, new Map([ + ['seq-remote-done', { + result: { + name: 'Remote Finished', + checkType: 'API', + responseTime: 25, + } as any, + titleString: 'Remote Finished', + numRetries: 0, + }], + ['seq-remote-pending', { + check: { name: 'Remote Pending', checkType: 'API' } as any, + titleString: 'Remote Pending', + numRetries: 0, + }], + ])], + ]) + + const markdown = new GithubMdBuilder({ + testSessionId, + numChecks: 3, + runLocation, + checkFilesMap: map, + }).render() + + expect(markdown).not.toContain('undefined') + expect(markdown).toContain('|✅ Pass|File Check|API|`folder/api.check.ts`|10ms ||') + expect(markdown).toContain('|✅ Pass|Remote Finished|API|-|25ms ||') + expect(markdown).toContain('|⏹️ Not finished|Remote Pending|API|-|- ||') + }) }) diff --git a/packages/cli/src/reporters/github.ts b/packages/cli/src/reporters/github.ts index f4c1f2c5b..3069bd38c 100644 --- a/packages/cli/src/reporters/github.ts +++ b/packages/cli/src/reporters/github.ts @@ -83,12 +83,13 @@ export class GithubMdBuilder { const retries = numRetries ? ` (${numRetries} ${numRetries === 1 ? 'retry' : 'retries'})` : '' if (!result) { // Only a run that stopped early leaves checks without a result. + const sourceFile = check?.getSourceFile?.() this.tableRows.push(this.tableSeparator + [ `⏹️ Not finished${retries}`, escapeCell((check as any)?.name), // Checks fetched for `checkly trigger` carry their type; local constructs do not. escapeCell((check as any)?.checkType ?? '-'), - this.hasFilenames ? `\`${escapeCell(check?.getSourceFile?.())}\`` : undefined, + this.hasFilenames ? (sourceFile ? `\`${escapeCell(sourceFile)}\`` : '-') : undefined, '- ', this.testSessionId ? '' : undefined, ].filter(nonNullable).join(this.tableSeparator) + this.tableSeparator) @@ -104,13 +105,15 @@ export class GithubMdBuilder { // A check that failed with a run error (e.g. the CLI timing out while waiting for // a result) has no check type or response time, so fall back to a placeholder. escapeCell(result.checkType ?? '-'), - this.hasFilenames ? `\`${escapeCell(result.sourceFile)}\`` : undefined, + this.hasFilenames ? (result.sourceFile ? `\`${escapeCell(result.sourceFile)}\`` : '-') : undefined, `${result.responseTime != null ? formatDuration(result.responseTime) : '-'} `, ].filter(nonNullable) if (this.testSessionId && testResultId) { const linkColumn = `[Full test report](${getTestSessionUrl(this.testSessionId)}/results/${testResultId})` tableRow.push(linkColumn) + } else if (this.testSessionId) { + tableRow.push('') } this.tableRows.push(this.tableSeparator + tableRow.join(this.tableSeparator) + this.tableSeparator) From e7afd4fd401a5024ac24ee41ad0e65fb7518a719 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Fri, 27 Nov 2026 03:31:14 +0900 Subject: [PATCH 2/2] refactor(cli): share the GitHub reporter's Filename and Link cell logic Co-Authored-By: Claude Opus 5.5 --- packages/cli/src/reporters/github.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/reporters/github.ts b/packages/cli/src/reporters/github.ts index 3069bd38c..d45e9d036 100644 --- a/packages/cli/src/reporters/github.ts +++ b/packages/cli/src/reporters/github.ts @@ -78,18 +78,23 @@ export class GithubMdBuilder { this.tableHeaders = this.tableHeaders.concat(this.extraTableHeadersWithLinks) } + // Under a Filename column, checks without a source file (e.g. fetched by `checkly trigger` + // alongside local ones) get a placeholder. + const fileCell = (sourceFile?: string) => this.hasFilenames + ? (sourceFile ? `\`${escapeCell(sourceFile)}\`` : '-') + : undefined + for (const [, checkMap] of this.checkFilesMap.entries()) { for (const [, { check, result, testResultId, numRetries }] of checkMap.entries()) { const retries = numRetries ? ` (${numRetries} ${numRetries === 1 ? 'retry' : 'retries'})` : '' if (!result) { // Only a run that stopped early leaves checks without a result. - const sourceFile = check?.getSourceFile?.() this.tableRows.push(this.tableSeparator + [ `⏹️ Not finished${retries}`, escapeCell((check as any)?.name), // Checks fetched for `checkly trigger` carry their type; local constructs do not. escapeCell((check as any)?.checkType ?? '-'), - this.hasFilenames ? (sourceFile ? `\`${escapeCell(sourceFile)}\`` : '-') : undefined, + fileCell(check?.getSourceFile?.()), '- ', this.testSessionId ? '' : undefined, ].filter(nonNullable).join(this.tableSeparator) + this.tableSeparator) @@ -105,15 +110,16 @@ export class GithubMdBuilder { // A check that failed with a run error (e.g. the CLI timing out while waiting for // a result) has no check type or response time, so fall back to a placeholder. escapeCell(result.checkType ?? '-'), - this.hasFilenames ? (result.sourceFile ? `\`${escapeCell(result.sourceFile)}\`` : '-') : undefined, + fileCell(result.sourceFile), `${result.responseTime != null ? formatDuration(result.responseTime) : '-'} `, ].filter(nonNullable) - if (this.testSessionId && testResultId) { - const linkColumn = `[Full test report](${getTestSessionUrl(this.testSessionId)}/results/${testResultId})` - tableRow.push(linkColumn) - } else if (this.testSessionId) { - tableRow.push('') + if (this.testSessionId) { + // A check that failed with a run error has no test result to link to, but its row + // still needs the cell to stay aligned with the header. + tableRow.push(testResultId + ? `[Full test report](${getTestSessionUrl(this.testSessionId)}/results/${testResultId})` + : '') } this.tableRows.push(this.tableSeparator + tableRow.join(this.tableSeparator) + this.tableSeparator)