Skip to content

Commit 2f1adfc

Browse files
authored
Merge pull request #36 from dhershman1/development
Development v4.2.0
2 parents 00af6bd + f413168 commit 2f1adfc

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If applicable, add screenshots to help explain your problem.
2828

2929
**Desktop (please complete the following information):**
3030
- OS: [e.g. iOS]
31-
- Browser [e.g. chrome, safari]
31+
- Node Version: [e.g. 14]
3232
- Version [e.g. 22]
3333

3434
**Additional context**

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ Silly small, silly easy junit output formatter for tap.
88

99
Works with [tape](https://github.com/substack/tape) and other tap based tests just pipe it into tap-junit
1010

11-
## Changelog
12-
13-
You can checkout the changelog at: https://github.com/dhershman1/tap-junit/blob/master/changelog.md
14-
1511
## Parameters
1612

1713
- `-c, --classname` - The name you want to apply to the `testsuite` element (if not set no name is given to the output testsuite)

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v4.2.0
4+
5+
### Improved
6+
7+
- Made the error diag more dynamic to handle different types of outputs instead of static and expecting
8+
39
## v4.1.0
410

511
### New

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tap-junit",
3-
"version": "4.1.0",
3+
"version": "4.2.0",
44
"description": "Silly small, silly easy junit output formatter for tap.",
55
"main": "src/index.js",
66
"bin": {
@@ -10,6 +10,7 @@
1010
"prepack": "npm run lint",
1111
"clear": "rimraf output/**",
1212
"test": "tape tests/pass.js | cross-env bin/tap-junit -o output/test -n pass -s suite-name -p",
13+
"ava": "bin/tap-junit --output output --name ava.xml --suite ava --input tests/ava.tap -p",
1314
"test:input": "cross-env bin/tap-junit --output output --name api.xuni --suite api-test --input tests/non-tape.tap",
1415
"test:zero": "tape tests/pass.js | cross-env bin/tap-junit > output/pass-zero.xml",
1516
"test:nontape": "cross-env bin/tap-junit --output output/test --name nontape.xml < tests/non-tape.tap",

src/serialize.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
const { EOL } = require('os')
22
const { create } = require('xmlbuilder2')
33

4-
function buildDetails (data) {
5-
if (!data) {
6-
return ''
7-
}
8-
9-
let str = '\n---\n'
10-
11-
for (const key in data) {
12-
str += `${key}: ${data[key]}\n`
13-
}
14-
15-
str += '---\n'
4+
function formatDiag (diag) {
5+
return Object.entries(diag).reduce((acc, [key, value]) => {
6+
if (typeof value === 'object') {
7+
acc.push(`${key}: \n ${formatDiag(value)}`)
8+
} else {
9+
acc.push(`${key}: ${value.replace(/\n/g, ' ')}`)
10+
}
1611

17-
return str
12+
return acc
13+
}, []).join('\n')
1814
}
1915

2016
/**
@@ -50,7 +46,11 @@ function buildFailureParams (fail, comment) {
5046
if (fail.diag) {
5147
failObj['@message'] = fail.diag.message
5248
failObj['@type'] = fail.diag.severity || 'fail'
53-
failObj['#'] = fail.todo ? `${fail.todo}\n ${comment}` : `${buildDetails(fail.diag.data)} ${comment}`
49+
failObj['#'] = fail.todo ? `${fail.todo}\n ${comment}` : `
50+
---
51+
${formatDiag(fail.diag)}
52+
...
53+
${comment}`
5454
} else {
5555
failObj['#'] = `\n${comment}`
5656
}

tests/ava.tap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
TAP version 13
2+
not ok 1 - 2+2=4
3+
---
4+
name: AssertionError
5+
assertion: is
6+
values:
7+
'Difference:': |-
8+
- 4
9+
+ 5
10+
at: 'test.js:4:4'
11+
...
12+
13+
1..1
14+
# tests 1
15+
# pass 0
16+
# fail 1

0 commit comments

Comments
 (0)