diff --git a/lib/middleware/karma.js b/lib/middleware/karma.js
index 4e27d4a52..3a34b4e58 100644
--- a/lib/middleware/karma.js
+++ b/lib/middleware/karma.js
@@ -191,7 +191,11 @@ function createKarmaMiddleware (
} else {
const scriptType = (SCRIPT_TYPE[fileType] || 'text/javascript')
const crossOriginAttribute = includeCrossOriginAttribute ? 'crossorigin="anonymous"' : ''
- scriptTags.push(``)
+ if (fileType === 'module') {
+ scriptTags.push(``)
+ } else {
+ scriptTags.push(``)
+ }
}
}
diff --git a/test/e2e/error.feature b/test/e2e/error.feature
index 0b327110e..09236959a 100644
--- a/test/e2e/error.feature
+++ b/test/e2e/error.feature
@@ -40,3 +40,19 @@ Feature: Error Display
"""
SyntaxError: Unexpected token '}'
"""
+
+Scenario: Missing module Error in a test file
+ Given a configuration with:
+ """
+ files = [{pattern: 'error/import-something-from-somewhere.js', type: 'module'}];
+ browsers = ['ChromeHeadlessNoSandbox'];
+ plugins = [
+ 'karma-jasmine',
+ 'karma-chrome-launcher'
+ ];
+ """
+ When I start Karma
+ Then it fails with:
+ """
+ Uncaught Error loading error/import-something-from-somewhere.js
+ """