File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,11 @@ function createKarmaMiddleware (
191191 } else {
192192 const scriptType = ( SCRIPT_TYPE [ fileType ] || 'text/javascript' )
193193 const crossOriginAttribute = includeCrossOriginAttribute ? 'crossorigin="anonymous"' : ''
194- scriptTags . push ( `<script type="${ scriptType } " src="${ filePath } " ${ crossOriginAttribute } ></script>` )
194+ if ( fileType === 'module' ) {
195+ scriptTags . push ( `<script onerror="throw 'Error loading ${ filePath } '" type="${ scriptType } " src="${ filePath } " ${ crossOriginAttribute } ></script>` )
196+ } else {
197+ scriptTags . push ( `<script type="${ scriptType } " src="${ filePath } " ${ crossOriginAttribute } ></script>` )
198+ }
195199 }
196200 }
197201
Original file line number Diff line number Diff line change @@ -40,3 +40,19 @@ Feature: Error Display
4040 """
4141 SyntaxError: Unexpected token '}'
4242 """
43+
44+ Scenario : Missing module Error in a test file
45+ Given a configuration with:
46+ """
47+ files = [{pattern: 'error/import-something-from-somewhere.js', type: 'module'}];
48+ browsers = ['ChromeHeadlessNoSandbox'];
49+ plugins = [
50+ 'karma-jasmine',
51+ 'karma-chrome-launcher'
52+ ];
53+ """
54+ When I start Karma
55+ Then it fails with:
56+ """
57+ Uncaught Error loading error/import-something-from-somewhere.js
58+ """
Original file line number Diff line number Diff line change 1+ import { something } from './somewhere.js'
2+ console . log ( something )
You can’t perform that action at this time.
0 commit comments