Skip to content

Commit

Permalink
Put only test filename and test case name into annotation title
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Nov 29, 2020
1 parent 198c3d1 commit d071a83
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions __tests__/__snapshots__/jest-junit.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Received: false
at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"path": "__tests__/main.test.js",
"start_line": 10,
"title": "Test Failed: 'Failing test' [__tests__\\\\main.test.js]",
"title": "[__tests__\\\\main.test.js] Failing test",
},
Object {
"annotation_level": "failure",
Expand All @@ -34,7 +34,7 @@ Received: false
at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"path": "lib/main.js",
"start_line": 2,
"title": "Test Failed: 'Exception in target unit' [__tests__\\\\main.test.js]",
"title": "[__tests__\\\\main.test.js] Exception in target unit",
},
Object {
"annotation_level": "failure",
Expand All @@ -49,7 +49,7 @@ Received: false
at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"path": "__tests__/main.test.js",
"start_line": 21,
"title": "Test Failed: 'Exception in test' [__tests__\\\\main.test.js]",
"title": "[__tests__\\\\main.test.js] Exception in test",
},
Object {
"annotation_level": "failure",
Expand All @@ -70,7 +70,7 @@ Received: false
at runTest (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-runner\\\\build\\\\runTest.js:472:34)",
"path": "__tests__/second.test.js",
"start_line": 1,
"title": "Test Failed: 'Timeout test' [__tests__\\\\second.test.js]",
"title": "[__tests__\\\\second.test.js] Timeout test",
},
],
"summary": "**6** tests were completed in **1.360s** with **1** passed, **1** skipped and **4** failed.
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/parsers/jest-junit/jest-junit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function parseJestJunit(content: string, options: ParseOptions): Pr
return {
success,
output: {
title: `${junit.testsuites.$.name} ${icon}`,
title: `${junit.testsuites.$.name.trim()} ${icon}`,
summary: getSummary(success, junit),
annotations: options.annotations ? getAnnotations(junit, options.workDir, options.trackedFiles) : undefined
}
Expand All @@ -42,7 +42,7 @@ function getSummary(success: boolean, junit: JunitReport): string {
const pass = ts.$.tests - fail - skip
const tm = `${ts.$.time.toFixed(3)}s`
const result = success ? Icon.success : Icon.fail
const tsName = ts.$.name
const tsName = ts.$.name.trim()
const tsAddr = makeSuiteSlug(i, tsName).link
const tsNameLink = link(tsName, tsAddr)
return [result, tsNameLink, ts.$.tests, tm, pass, fail, skip]
Expand Down Expand Up @@ -80,12 +80,12 @@ function getSuiteSummary(suite: TestSuite, index: number): string {

const content = groups
.map(grp => {
const header = grp.describe !== '' ? `### ${grp.describe}\n\n` : ''
const header = grp.describe !== '' ? `### ${grp.describe.trim()}\n\n` : ''
const tests = table(
['Result', 'Test', 'Time'],
[Align.Center, Align.Left, Align.Right],
...grp.tests.map(tc => {
const name = tc.$.name
const name = tc.$.name.trim()
const time = `${Math.round(tc.$.time * 1000)}ms`
const result = getTestCaseIcon(tc)
return [result, name, time]
Expand All @@ -96,7 +96,7 @@ function getSuiteSummary(suite: TestSuite, index: number): string {
})
.join('\n')

const tsName = suite.$.name
const tsName = suite.$.name.trim()
const tsSlug = makeSuiteSlug(index, tsName)
const tsNameLink = `<a id="${tsSlug.id}" href="${tsSlug.link}">${tsName}</a>`
return `## ${tsNameLink} ${icon}\n\n${content}`
Expand Down Expand Up @@ -131,7 +131,7 @@ function getAnnotations(junit: JunitReport, workDir: string, trackedFiles: strin
end_line: src.line,
path: src.file,
message: ex,
title: `Test Failed: '${tc.$.name}' [${suite.$.name}]`
title: `[${suite.$.name}] ${tc.$.name.trim()}`
})
}
}
Expand Down

0 comments on commit d071a83

Please sign in to comment.