If the program being tested leverages prepareStackTrace then line numbers for a failed test are incorrect
#10463
Replies: 2 comments
-
|
So I would not register Practical options I would try, in this order:
import 'source-map-support/register.js'
vi.mock('source-map-support/register.js', () => ({}))or mock the module that imports it before importing the code under test.
I do not think there is a reliable local fix that lets both Vitest and |
Beta Was this translation helpful? Give feedback.
-
|
@chrisjcthomas Am thinking I will need to go back into the source for the modules that are doing the import, and change it to a conditional import when running running outside of vitest. Looking at process.env, I can see
So a simple test to see if your running VITEST, should work. Thanks very much |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Recently identified this when testing plugins for the package
homebridge, and found that when a test fails the source map shown is at an incorrect location.And after some intense digging found that the issue is triggered by our usage of the package
source-map-support, and its internal usage ofprepareStackTrace.We dig a far bit of digging and could not find a workaround for the issue, and was wondering if the community had anything.
package.json
Test
Environment
Beta Was this translation helpful? Give feedback.
All reactions