return api.get(mapUrl).then(function (response) { var map = sourceMap.SourceMapConsumer(response.body); var position = positionOf(js, 'return"browserify-server-test"'); expect(position).to.exist; expect(map.originalPositionFor(position)).to.eql({ source: 'browserify-server-test', line: 2, column: 0, name: null }); });
function applySourceMap( generatedId: string, url: string, code: string, mappings: Object ) { const generator = new SourceMapGenerator({ file: url }); mappings.forEach(mapping => generator.addMapping(mapping)); generator.setSourceContent(url, code); const map = SourceMapConsumer(generator.toJSON()); setSourceMap(generatedId, Promise.resolve(map)); }