Forked from asheb/mocha-source-map-reporter.coffee
Last active
August 29, 2015 14:25
-
-
Save wmakeev/11b7f5c2d73c9c9a2aab to your computer and use it in GitHub Desktop.
Dirty hack to make 'source-map-support' work with mocha in PhantomJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sourceMapper = require 'source-map-support' | |
Dot = require '../../../node_modules/grunt-mocha/node_modules/mocha/lib/reporters/dot.js' | |
module.exports = Dot | |
## | |
parseLine = (line) -> | |
[_, file, row] = line.match /file:\/\/\/(.*):(\d*)/ | |
frame = | |
getFileName: -> file | |
getLineNumber: -> row | |
getColumnNumber: -> 1 | |
superEpilogue = Dot.prototype.epilogue | |
Dot.prototype.epilogue = -> | |
for test in @failures | |
test.err.stack = test.err.stack.split('\n').map((line)-> | |
if line.match /^ at / | |
mapped = sourceMapper.wrapCallSite parseLine line | |
line.replace /file:\/\/\/(.*):(\d*)/, | |
"file:///#{mapped.getFileName()}:#{mapped.getLineNumber()}" | |
else | |
line | |
).join('\n') | |
superEpilogue.bind(@)() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment