(I believe this might be the cause of webdriverio/webdriverio#1726)
Scenario:
a failing test throws an error
the error gets caught and passed to sanitizeErrorMessage to fix its stack trace
the error stack is only two-lines long, therefore the stack array has length 2
at least two elements are removed by the stack array (since it's shift-ed twice)
the stack array is now empty, and lineToFix is undefined, which causes a TypeError: Cannot read property 'indexOf' of undefined
(I can reproduce this in a client project I'm working on that I can't share, let me know if an "open reproduction" is needed)
The error is a bit erratic. On my local machine (macOS), with the exact same run, sometimes it happens, sometimes it doesn't, meaning sometimes the stack trace has 2 lines, sometimes 3. In a docker container (ubuntu) it appears to be systematic. I did not succeed to pinpoint the reason behind that.
This pull request attempts to fix the error described above by adding an undefined-check on lineToFix. Now when lineToFix === undefined the else case will be executed. I'm not sure if that is the correct/desired fallback though.
(I believe this might be the cause of webdriverio/webdriverio#1726)
Scenario:
sanitizeErrorMessage
to fix its stack tracestack
array has length 2stack
array (since it'sshift
-ed twice)stack
array is now empty, andlineToFix
isundefined
, which causes aTypeError: Cannot read property 'indexOf' of undefined
(I can reproduce this in a client project I'm working on that I can't share, let me know if an "open reproduction" is needed)
The error is a bit erratic. On my local machine (macOS), with the exact same run, sometimes it happens, sometimes it doesn't, meaning sometimes the stack trace has 2 lines, sometimes 3. In a docker container (ubuntu) it appears to be systematic. I did not succeed to pinpoint the reason behind that.
This pull request attempts to fix the error described above by adding an undefined-check on
lineToFix
. Now whenlineToFix === undefined
theelse
case will be executed. I'm not sure if that is the correct/desired fallback though.