Skip to content

Commit

Permalink
reporter: get rid of extraneous {} in error result
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 24, 2023
1 parent 0f41fe1 commit 885a15e
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 40 deletions.
29 changes: 14 additions & 15 deletions src/reporter/src/result-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,23 @@ export const ResultDetails: FC<{ result: Result }> = ({ result }) => {
errorOrigin={errorOrigin}
/>
<Diff diff={diff} />
{error && typeof error === 'string' ? (
<Box flexDirection="row">
<Text>
{stringify({ error })
.trimEnd()
.replace(/^error:([^\n]*\n)?/, chalk.dim('error:$1'))}
</Text>
</Box>
{error ? (
<Text>
{stringify({ error })
.trimEnd()
.replace(/^error:([^\n]*\n)?/, chalk.dim('error:$1'))}
</Text>
) : (
<Text dimColor>{stringify({ error }).trimEnd()}</Text>
<></>
)}
{code && typeof code === 'string' ? (
<Box flexDirection="row" gap={1}>
<Text dimColor>code:</Text>
<Text>{stringify(code).trimEnd()}</Text>
</Box>
{code ? (
<Text>
{stringify({ code })
.trimEnd()
.replace(/^code:([^\n]*\n)?/, chalk.dim('code:$1'))}
</Text>
) : (
<Text dimColor>{stringify({ error }).trimEnd()}</Text>
<></>
)}
{!!Object.keys(otherDiags).length && (
<Text dimColor>{stringify(otherDiags).trimEnd()}</Text>
Expand Down
4 changes: 0 additions & 4 deletions src/reporter/tap-snapshots/test/base.tsx.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ exports[`test/base.tsx > TAP > no comments or passes > must match snapshot 1`] =
19  t.pass('skip', { skip: true }) 
20  t.comment('comment in two') 
21  }) 
{}
{}
XXX mock stack XXX
 SKIP  two 1 skip of 1 {TIME}
Expand Down Expand Up @@ -104,8 +102,6 @@ exports[`test/base.tsx > TAP > yes comments and passes > must match snapshot 1`]
19  t.pass('skip', { skip: true }) 
20  t.comment('comment in two') 
21  }) 
{}
{}
XXX mock stack XXX
 SKIP  two 1 skip of 1 {TIME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ exports[`test/result-detail-list.tsx > TAP > no banner > must match snapshot 1`]
19  t.pass('skip', { skip: true }) 
20  t.comment('comment in two') 
21  }) 
{}
{}
XXX mock stack XXX
 SKIP  two 1 skip of 1 {TIME}
Expand Down Expand Up @@ -51,8 +49,6 @@ hello
19  t.pass('skip', { skip: true }) 
20  t.comment('comment in two') 
21  }) 
{}
{}
XXX mock stack XXX
 SKIP  two 1 skip of 1 {TIME}
Expand Down
15 changes: 10 additions & 5 deletions src/reporter/tap-snapshots/test/result-details.tsx.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ exports[`test/result-details.tsx > TAP > diff > diags and details 1`] = `
AT {"mock":"callsite"}
SOURCE mock source
DIFF mock diff
{}
{}
compare: ===
some:
 other:
 diags: true
STACK mock stack
`

exports[`test/result-details.tsx > TAP > error that is not a string > diags and details 1`] = `
AT {"mock":"callsite"}
SOURCE mock source
DIFF mock diff
error:
number: 42069
msg: lolz
STACK mock stack
`

exports[`test/result-details.tsx > TAP > error without code > diags and details 1`] = `
AT {"mock":"callsite"}
SOURCE mock source
DIFF mock diff
error: message
error: message
STACK mock stack
`

Expand All @@ -40,8 +47,6 @@ exports[`test/result-details.tsx > TAP > no diff, but expected and actual > gene
+ },
}
{}
{}
operator: deepEqual
STACK mock stack
`
Expand Down
2 changes: 0 additions & 2 deletions src/reporter/tap-snapshots/test/result-tag.tsx.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ exports[`test/result-tag.tsx > TAP > fail, with diag and details > must match sn
+ "x": 2, 
+ "y": 1 
 } 
{}
{}
`

exports[`test/result-tag.tsx > TAP > fail, with diag, no line/column numbers > must match snapshot 1`] = `
Expand Down
4 changes: 0 additions & 4 deletions src/reporter/tap-snapshots/test/terse.tsx.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ exports[`test/terse.tsx > TAP > no comments or passes > must match snapshot 1`]
19  t.pass('skip', { skip: true }) 
20  t.comment('comment in two') 
21  }) 
{}
{}
XXX mock stack XXX
 TODO  fur 1 todo of 1 {TIME}
Expand Down Expand Up @@ -56,8 +54,6 @@ exports[`test/terse.tsx > TAP > yes comments and passes > must match snapshot 1`
19  t.pass('skip', { skip: true }) 
20  t.comment('comment in two') 
21  }) 
{}
{}
XXX mock stack XXX
 TODO  fur 1 todo of 1 {TIME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,5 @@ exports[`test/test-results-list.tsx > TAP > test with other types of points > mu
✖ not so fine
SOURCE
{}
{}
STACK
`
4 changes: 0 additions & 4 deletions src/reporter/tap-snapshots/test/test-summary.tsx.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ exports[`test/test-summary.tsx > TAP > all the details > must match snapshot 1`]
80  tb.fail('skip msg', { skip: 'message' }) 
81  tb.fail('todo', { todo: true }) 
82  tb.pass('todo msg', { todo: 'message' }) 
{}
{}
XXX mock stack XXX
`

Expand Down Expand Up @@ -54,8 +52,6 @@ exports[`test/test-summary.tsx > TAP > failing test with details > must match sn
55  await tb.concat() 
56  t.matchSnapshot( 
57  render(<TestSummary details test={tb} />).lastFrame() 
{}
{}
XXX mock stack XXX
`

Expand Down
31 changes: 31 additions & 0 deletions src/reporter/test/result-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,37 @@ t.test('error without code', t => {
t.end()
})

t.test('error that is not a string', t => {
const res = {
ok: true,
name: 'fake result',
id: 1,
buffered: false,
skip: false,
previous: null,
plan: null,
diag: {
at: {
mock: 'callsite',
},
stack: 'mock stack',
source: 'mock source',
diff: 'mock diff',
error: {
number: 42069,
msg: 'lolz',
},
},
time: null,
fullname: 'test name > fake result',
} as Result
t.matchSnapshot(
render(<ResultDetails result={res} />).lastFrame(),
'diags and details'
)
t.end()
})

t.test('diff', t => {
const res = {
ok: true,
Expand Down

0 comments on commit 885a15e

Please sign in to comment.