Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reporter): Ensure errors use the source map #1513

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) {
return null
}

var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*\\/' +
var URL_REGEXP = new RegExp('(?:http:\\/\\/[^\\/]*)?\\/?' +
'(base|absolute)' + // prefix
'((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path
'(\\?\\w*)?' + // sha
Expand Down
15 changes: 14 additions & 1 deletion test/unit/reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe 'reporter', ->
it 'should handle empty message', ->
expect(formatError null).to.equal '\n'


it 'should remove domain from files', ->
expect(formatError 'file http://localhost:8080/base/usr/a.js and ' +
'http://127.0.0.1:8080/base/home/b.js').
Expand Down Expand Up @@ -99,6 +98,20 @@ describe 'reporter', ->
done()
, 100

it 'should rewrite relative url stack traces', (done) ->
formatError = m.createErrorFormatter '/some/base', emitter, MockSourceMapConsumer
servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')]
servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'}
servedFiles[1].sourceMap = {content: 'SOURCE MAP b.js'}

emitter.emit 'file_list_modified', served: servedFiles

_.defer -> _.delay ->
ERROR = 'at /base/b.js:2:6'
expect(formatError ERROR).to.equal 'at /some/base/b.js:2:6 <- /original/b.js:4:8\n'
done()
, 100

it 'should fall back to non-source-map format if originalPositionFor throws', (done) ->
formatError = m.createErrorFormatter '/some/base', emitter, MockSourceMapConsumer
servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')]
Expand Down