diff --git a/lib/middleware/karma.js b/lib/middleware/karma.js
index 6836af577..31c5509c2 100644
--- a/lib/middleware/karma.js
+++ b/lib/middleware/karma.js
@@ -18,7 +18,8 @@ var common = require('./common');
var VERSION = require('../constants').VERSION;
var SCRIPT_TAG = '';
-var LINK_TAG = '';
+var LINK_TAG_CSS = '';
+var LINK_TAG_HTML = '';
var SCRIPT_TYPE = {
'.js': 'text/javascript',
'.dart': 'application/dart'
@@ -88,7 +89,11 @@ var createKarmaMiddleware = function(filesPromise, serveStaticFile,
}
if (fileExt === '.css') {
- return util.format(LINK_TAG, filePath);
+ return util.format(LINK_TAG_CSS, filePath);
+ }
+
+ if (fileExt === '.html') {
+ return util.format(LINK_TAG_HTML, filePath);
}
return util.format(SCRIPT_TAG, SCRIPT_TYPE[fileExt] || 'text/javascript', filePath);
diff --git a/test/unit/middleware/karma.spec.coffee b/test/unit/middleware/karma.spec.coffee
index f85554bf5..71146126f 100644
--- a/test/unit/middleware/karma.spec.coffee
+++ b/test/unit/middleware/karma.spec.coffee
@@ -122,17 +122,18 @@ describe 'middleware.karma', ->
it 'should serve context.html with replaced link tags', (done) ->
includedFiles [
new MockFile('/first.css', 'sha007')
+ new MockFile('/second.html', 'sha678')
]
response.once 'end', ->
expect(nextSpy).not.to.have.been.called
expect(response).to.beServedAs 200, 'CONTEXT\n' +
- ''
+ '\n' +
+ ''
done()
callHandlerWith '/__karma__/context.html'
-
it 'should serve context.html with the correct path for the script tags', (done) ->
includedFiles [
new MockFile('/some/abc/a.js', 'sha')
@@ -153,13 +154,17 @@ describe 'middleware.karma', ->
includedFiles [
new MockFile('/some/abc/a.css', 'sha1')
new MockFile('/base/path/b.css', 'sha2')
+ new MockFile('/some/abc/c.html', 'sha3')
+ new MockFile('/base/path/d.html', 'sha4')
]
response.once 'end', ->
expect(nextSpy).not.to.have.been.called
expect(response).to.beServedAs 200, 'CONTEXT\n' +
'\n' +
- ''
+ '\n' +
+ '\n' +
+ ''
done()
callHandlerWith '/__karma__/context.html'
@@ -231,13 +236,17 @@ describe 'middleware.karma', ->
includedFiles [
new MockFile('/first.css')
new MockFile('/base/path/b.css')
+ new MockFile('/second.html')
+ new MockFile('/base/path/d.html')
]
response.once 'end', ->
expect(nextSpy).not.to.have.been.called
expect(response).to.beServedAs 200, 'DEBUG\n' +
'\n' +
- ''
+ '\n' +
+ '\n' +
+ ''
done()
callHandlerWith '/__karma__/debug.html'