Skip to content

Commit b884302

Browse files
committed
test: stack parser throws error
1 parent 31fab66 commit b884302

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,44 @@ test('RedBox stack trace with missing filename', t => {
272272

273273
afterEach()
274274
})
275+
276+
test('RedBox with throwing stack trace parser', t => {
277+
t.plan(1)
278+
RedBox.__Rewire__('ErrorStackParser', {
279+
parse: function () {
280+
// This mimicks the former behavior of stacktracejs,
281+
// see https://github.com/stacktracejs/stackframe/issues/11.
282+
throw new TypeError("Line Number must be a Number")
283+
}
284+
})
285+
const ERR_MESSAGE = "original error message"
286+
const error = new TypeError(ERR_MESSAGE)
287+
const component = createComponent(RedBox, {error})
288+
289+
const renderedError = component
290+
.props.children[0]
291+
.props.children
292+
t.equal(
293+
renderedError[0],
294+
'TypeError',
295+
'Main error message begins with error type of original error'
296+
)
297+
t.equal(
298+
renderedError[2],
299+
ERR_MESSAGE,
300+
'Main error message ends with message originally supplied to error constructor.'
301+
)
302+
const renderedStack = component
303+
.props.children[1]
304+
305+
t.deepEqual(
306+
renderedStack,
307+
<div style={style.stack}>
308+
<div style={style.frame} key={0}>
309+
<div>Failed to parse stack trace. Stack trace information unavailable.</div>
310+
</div>
311+
</div>
312+
)
313+
314+
afterEach()
315+
})

0 commit comments

Comments
 (0)