Closed
Description
Currently the stacktraces returned by karma are pretty much useless if any source code transformation or bundling is taking place. This impacts workflows using bundlers (e.g. browserify, component) and transpilers (e.g. CoffeeScript, LiveScript, TypeScript, Dart) alike.
As karma seems to be able to print stacktraces from the browser to the console, it should be possible to run a function on them in between.
Mozilla provides a library at mozilla/source-map for parsing sourcemaps and translating generated source positions to original source positions and filenames.
From what I can see this would require the following steps:
- When a source file is loaded, try to find source map comments.
- Parse any inlined source maps (needs to support base64-encoded data URLs)
- When a browser returns a stacktrace, try to find any file/line/col references.
- Translate per-file line/col references via mozilla/source-map.
This should probably be optional because of the overhead involved in finding, parsing and applying the source maps.