Skip to content

Commit

Permalink
fix(reporter): Fix issue causing error stack not to be parsed correctly
Browse files Browse the repository at this point in the history
Closes #2930
  • Loading branch information
doberkofler authored and dignifiedquire committed Mar 1, 2018
1 parent d1effbf commit ac4e1a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var baseReporterDecoratorFactory = require('./reporters/base').decoratorFactory

var createErrorFormatter = function (config, emitter, SourceMapConsumer) {
var basePath = config.basePath
var urlRoot = config.urlRoot || ''
var urlRoot = config.urlRoot === '/' ? '' : (config.urlRoot || '')
var lastServedFiles = []

emitter.on('file_list_modified', function (files) {
Expand Down
15 changes: 15 additions & 0 deletions test/unit/reporter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ describe('reporter', () => {
})
})

it('should rewrite stack traces (when basePath is empty)', (done) => {
formatError = m.createErrorFormatter({ basePath: '', hostname: 'localhost', port: 123 }, emitter, MockSourceMapConsumer)
var servedFiles = [new File('/a.js'), new File('/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(() => {
var ERROR = 'at http://localhost:123/base/b.js:2:6'
expect(formatError(ERROR)).to.equal('at /original/b.js:4:8 <- b.js:2:6\n')
done()
})
})

it('should rewrite stack traces to the first column when no column is given', (done) => {
formatError = m.createErrorFormatter({ basePath: '/some/base', hostname: 'localhost', port: 123 }, emitter, MockSourceMapConsumer)
var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')]
Expand Down

1 comment on commit ac4e1a9

@lusarz
Copy link
Contributor

@lusarz lusarz commented on ac4e1a9 Mar 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @doberkofler

Please sign in to comment.