{"action":"closed","issue":{"url":"https://api.github.com/repos/SitePen/remap-istanbul/issues/55","repository_url":"https://api.github.com/repos/SitePen/remap-istanbul","labels_url":"https://api.github.com/repos/SitePen/remap-istanbul/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/SitePen/remap-istanbul/issues/55/comments","events_url":"https://api.github.com/repos/SitePen/remap-istanbul/issues/55/events","html_url":"https://github.com/SitePen/remap-istanbul/issues/55","id":153093227,"number":55,"title":"remap.js - False negatives due to improper handling of embedded source code","user":{"login":"traviskaufman","id":1185269,"avatar_url":"https://avatars.githubusercontent.com/u/1185269?v=3","gravatar_id":"","url":"https://api.github.com/users/traviskaufman","html_url":"https://github.com/traviskaufman","followers_url":"https://api.github.com/users/traviskaufman/followers","following_url":"https://api.github.com/users/traviskaufman/following{/other_user}","gists_url":"https://api.github.com/users/traviskaufman/gists{/gist_id}","starred_url":"https://api.github.com/users/traviskaufman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/traviskaufman/subscriptions","organizations_url":"https://api.github.com/users/traviskaufman/orgs","repos_url":"https://api.github.com/users/traviskaufman/repos","events_url":"https://api.github.com/users/traviskaufman/events{/privacy}","received_events_url":"https://api.github.com/users/traviskaufman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SitePen/remap-istanbul/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-04T19:19:10Z","updated_at":"2016-05-12T11:37:31Z","closed_at":"2016-05-12T11:37:31Z","body":"In `lib/remap.js` there's a [line of code](https://github.com/SitePen/remap-istanbul/blob/f4b09bc/lib/remap.js#L189) that detects whether or not source code is embedded and if so uses that code. However, it assumes this property is a string (e.g. in the [fixture](https://github.com/SitePen/remap-istanbul/blob/f4b09bccd65be23668a3d6ad8656ff1fe033fe1a/tests/unit/support/coverage-code.json) for the corresponding test). This is incorrect as `code` is an [array](https://github.com/gotwarlost/istanbul/blob/ad8ab1d7a5284407efb83d0d7a8b32eb6fbd93c4/lib/instrumenter.js#L358).\r\n\r\nAs a consequence, when the source map regex is tested against this proper, the array is stringified and as a result, a `,` may be appended to what would be considered the \"source map name\" if there are extra newlines at the end of the file. This results in remap-istanbul reporting that it cannot find the file.\r\n\r\nThis is probably occurring due to a version update from istanbul that they considered backwards-compatible. You could support this in a backwards-compatible way by adding the following to remap.js:\r\n\r\n```javascript\r\nvar jsText = fileCoverage.code || readFile(filePath); /* line 189 @ f4b09bc */ \r\nif (Array.isArray(jsText)) {\r\n  jsText = jsText.join('\\n');\r\n}\r\n// ...\r\n```\r\n\r\nI'd be happy to submit this PR myself but TBH it could probably be fixed by the time I went through the song and dance of getting your CLA signed off on :)\r\n\r\nIn the meantime, a workaround for tools like karma might be to have their coverage preprocessor tell istanbul to disable embedding source code."}}