Skip to content

Commit

Permalink
fix(middleware): Catch errors when loading a module
Browse files Browse the repository at this point in the history
Fix #3572
  • Loading branch information
jehon committed Nov 13, 2020
1 parent 05dc288 commit 380251c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ function createKarmaMiddleware (
} else {
const scriptType = (SCRIPT_TYPE[fileType] || 'text/javascript')
const crossOriginAttribute = includeCrossOriginAttribute ? 'crossorigin="anonymous"' : ''
scriptTags.push(`<script type="${scriptType}" src="${filePath}" ${crossOriginAttribute}></script>`)
if (fileType === 'module') {
scriptTags.push(`<script onerror="throw 'Error loading ${filePath}'" type="${scriptType}" src="${filePath}" ${crossOriginAttribute}></script>`)
} else {
scriptTags.push(`<script type="${scriptType}" src="${filePath}" ${crossOriginAttribute}></script>`)
}
}
}

Expand Down

0 comments on commit 380251c

Please sign in to comment.