File tree 3 files changed +23
-1
lines changed
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,11 @@ function createKarmaMiddleware (
191
191
} else {
192
192
const scriptType = ( SCRIPT_TYPE [ fileType ] || 'text/javascript' )
193
193
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
+ }
195
199
}
196
200
}
197
201
Original file line number Diff line number Diff line change @@ -40,3 +40,19 @@ Feature: Error Display
40
40
"""
41
41
SyntaxError: Unexpected token '}'
42
42
"""
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