Skip to content

Commit

Permalink
feat: add TAP format
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Dec 13, 2024
1 parent 77cfb0b commit aff7b5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'shared');

export const resultFormatFlag = Flags.option({
options: [
'json',
'human',
'junit',
// 'tap',
] as const,
options: ['json', 'human', 'junit', 'tap'] as const,
default: 'human',
summary: messages.getMessage('flags.result-format.summary'),
});
Expand Down
12 changes: 10 additions & 2 deletions src/handleTestResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { join } from 'node:path';
import { writeFile, mkdir } from 'node:fs/promises';
import { AgentTestDetailsResponse, jsonFormat, humanFormat, junitFormat } from '@salesforce/agents';
import { AgentTestDetailsResponse, jsonFormat, humanFormat, junitFormat, tapFormat } from '@salesforce/agents';
import { Ux } from '@salesforce/sf-plugins-core/Ux';

async function writeFileToDir(outputDir: string, fileName: string, content: string): Promise<void> {
Expand All @@ -24,7 +24,7 @@ export async function handleTestResults({
outputDir,
}: {
id: string;
format: 'human' | 'json' | 'junit';
format: 'human' | 'json' | 'junit' | 'tap';
results: AgentTestDetailsResponse | undefined;
jsonEnabled: boolean;
outputDir?: string;
Expand Down Expand Up @@ -59,4 +59,12 @@ export async function handleTestResults({
await writeFileToDir(outputDir, `test-result-${id}.xml`, formatted);
}
}

if (format === 'tap') {
const formatted = await tapFormat(results);
ux.log(formatted);
if (outputDir) {
await writeFileToDir(outputDir, `test-result-${id}.txt`, formatted);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"startTime": "2024-11-28T12:00:00Z",
"endTime": "2024-11-28T12:05:00Z",
"errorMessage": null,
"subjectName": "Copilot_for_Salesforce",
"testSetName": "CRM_Sanity_v1",
"testCases": [
{
"status": "COMPLETED",
Expand Down

0 comments on commit aff7b5b

Please sign in to comment.