diff --git a/__tests__/dotnet-trx.test.ts b/__tests__/dotnet-trx.test.ts index c10b997..ba225c4 100644 --- a/__tests__/dotnet-trx.test.ts +++ b/__tests__/dotnet-trx.test.ts @@ -65,7 +65,8 @@ describe('dotnet-trx tests', () => { listTests: 'failed', onlySummary: false, slugPrefix: '', - baseUrl: '' + baseUrl: '', + stackTraceInSummary: false } const report = getReport([result], reportOptions) fs.mkdirSync(path.dirname(outputPath), {recursive: true}) diff --git a/src/main.ts b/src/main.ts index 732d839..4d81413 100644 --- a/src/main.ts +++ b/src/main.ts @@ -54,6 +54,7 @@ class TestReporter { readonly workDirInput = core.getInput('working-directory', {required: false}) readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true' readonly outputTo = core.getInput('output-to', {required: false}) + readonly stackTraceInSummary = this.outputTo === 'step-summary' ? true : false readonly token = core.getInput('token', {required: true}) readonly slugPrefix: string = '' readonly octokit: InstanceType @@ -205,8 +206,8 @@ class TestReporter { } core.info('Creating report summary') - const {listSuites, listTests, onlySummary, slugPrefix} = this - const summary = getReport(results, {listSuites, listTests, baseUrl, slugPrefix, onlySummary}) + const {listSuites, listTests, onlySummary, slugPrefix, stackTraceInSummary} = this + const summary = getReport(results, {listSuites, listTests, baseUrl, slugPrefix, onlySummary, stackTraceInSummary}) core.info('Creating annotations') const annotations = getAnnotations(results, this.maxAnnotations) diff --git a/src/report/get-report.ts b/src/report/get-report.ts index fb90f01..d38506c 100644 --- a/src/report/get-report.ts +++ b/src/report/get-report.ts @@ -12,6 +12,7 @@ export interface ReportOptions { slugPrefix: string baseUrl: string onlySummary: boolean + stackTraceInSummary: boolean } const defaultOptions: ReportOptions = { @@ -19,7 +20,8 @@ const defaultOptions: ReportOptions = { listTests: 'all', slugPrefix: '', baseUrl: '', - onlySummary: false + onlySummary: false, + stackTraceInSummary: false } export function getReport(results: TestRunResult[], options: ReportOptions = defaultOptions): string { @@ -239,9 +241,13 @@ function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: numbe const result = getResultIcon(tc.result) sections.push(`${space}${result} ${tc.name}`) if (tc.error) { - const lines = (tc.error.message ?? getFirstNonEmptyLine(tc.error.details)?.trim()) - ?.split(/\r?\n/g) - .map(l => '\t' + l) + let errorData = '' + if (options.stackTraceInSummary) { + errorData = tc.error.details ?? '' + } else { + errorData = tc.error.message ?? getFirstNonEmptyLine(tc.error.details)?.trim() ?? '' + } + const lines = errorData.split(/\r?\n/g).map(l => '\t' + l) if (lines) { sections.push(...lines) }