Starting v3.0.0, I'm seeing this error:
SyntaxError: Unexpected token m in JSON at position 0
at JSON.parse (<anonymous>)
at Object.parseSourceMapInput (node_modules/source-map-support/node_modules/source-map/lib/util.js:433:15)
at new SourceMapConsumer (node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:17:22)
at mapSourcePosition (node_modules/source-map-support/source-map-support.js:190:14)
at wrapCallSite (node_modules/source-map-support/source-map-support.js:358:20)
at node_modules/source-map-support/source-map-support.js:395:26
at Array.map (<anonymous>)
at Function.prepareStackTrace (node_modules/source-map-support/source-map-support.js:394:24)
at Generator.throw (<anonymous>)
when trying to import a .vue file like below into a Jest test:
<script>
export default {
render: h => h('div')
}
</script>
<style module>
.foo {
color: orange;
}
</style>
The error even occurs with just:
<style module>
</style>
It goes away as soon as I add a <template> tag, e.g.:
```.vue
```
I am also experiencing the same issue. A bit of tracing led me to the jest-runner package which has a dependency on package source-map-support. It seems to be something to do with the way source maps are generated for the file https://github.com/vuejs/vue-jest/blob/master/lib/process.js. Check the lines at the bottom of the file:
const base64Map = Buffer.from(JSON.stringify(map)).toString('base64')
output += `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
When the function retrieveMapHandlers in source-map-support.js (line 155) extracts the line:
output += `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
It does so without evaluating the ${base64Map} template literal. So when it tries to base64 decode the string it returns m instead of the JSON string map in the variable base64Map.
At least that is what I think is going on. Some of these packages have been updated in the last few weeks but haven't had a chance to further investigate. Anyone familiar with how these packages work together?
This is fixed in 3.0.1
Most helpful comment
This is fixed in 3.0.1