Created
July 20, 2014 09:39
-
-
Save asheb/8f67d55ef597329d266e to your computer and use it in GitHub Desktop.
Dirty hack to make 'source-map-support' work with mocha in PhantomJS
This file contains 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