diff --git a/cypress/e2e/fix-source-paths.cy.js b/cypress/e2e/fix-source-paths.cy.js index c4e964ea..8d471a4e 100644 --- a/cypress/e2e/fix-source-paths.cy.js +++ b/cypress/e2e/fix-source-paths.cy.js @@ -24,7 +24,7 @@ describe('fixSourcePaths', () => { '/absolute/src/component.vue': { path: '/absolute/src/component.vue', inputSourceMap: { - sources: ['/absolute/src/component.vue', 'otherFile.js'], + sources: ['/absolute/src/component.vue', 'src/otherFile.js'], sourceRoot: '' } }, diff --git a/support-utils.js b/support-utils.js index 6f2a43f1..05b6741a 100644 --- a/support-utils.js +++ b/support-utils.js @@ -141,10 +141,12 @@ function fixSourcePaths(coverage) { const fileName = /([^\/\\]+)$/.exec(absolutePath)[1] if (!fileName) return - if (inputSourceMap.sourceRoot) inputSourceMap.sourceRoot = '' inputSourceMap.sources = inputSourceMap.sources.map((source) => - source.includes(fileName) ? absolutePath : source + source.includes(fileName) + ? absolutePath + : `${inputSourceMap.sourceRoot}/${source}` ) + if (inputSourceMap.sourceRoot) inputSourceMap.sourceRoot = '' }) }