Skip to content

Commit

Permalink
reporter: handle case where we have location, not stack
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 19, 2023
1 parent 4b20f9a commit cbb9fc6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/reporter/src/source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ export const Source: FC<SourceOpts> = ({
</>
)
}
if (location && !stack) {
return (
<Source
{...{
source,
at,
errorOrigin,
stack: location,
isErrorOrigin,
}}
/>
)
}
if (stack && !at) {
if (location) {
return (
Expand Down
13 changes: 13 additions & 0 deletions src/reporter/tap-snapshots/test/source.tsx.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ exports[`test/source.tsx > TAP > get at from stack > must match snapshot 2`] = `
 83  } 
`

exports[`test/source.tsx > TAP > get at from stack > must match snapshot 3`] = `
test/source.tsx 
 91  getStack(), 
 92  ] 
 93  } 
 94  const test = () => getStackAndLocation() 
 ━━━━━━━━━━━━━━━━━━━━━━━━┛ 
 95  const app = render(<Source stack={getStack()} />) 
 96  t.matchSnapshot(app.lastFrame()) 
 97  const [ location, stack ] = test() 
 98  const withLoc = render(<Source stack={stack} location={location} />)
`

exports[`test/source.tsx > TAP > show diag source if provided and callsite invalid > must match snapshot 1`] = `
diag source
`
Expand Down
2 changes: 2 additions & 0 deletions src/reporter/test/source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,7 @@ t.test('get at from stack', t => {
const [ location, stack ] = test()
const withLoc = render(<Source stack={stack} location={location} />)
t.matchSnapshot(withLoc.lastFrame())
const locOnly = render(<Source location={location} />)
t.matchSnapshot(locOnly.lastFrame())
t.end()
})

0 comments on commit cbb9fc6

Please sign in to comment.