mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-27 11:22:16 +00:00
Handle fake images in karma, preventing 404 warnings
This commit is contained in:
parent
d93f5fa6be
commit
ef0b550234
1 changed files with 15 additions and 1 deletions
|
@ -27,6 +27,7 @@ module.exports = function (config) {
|
||||||
// Include ES test files
|
// Include ES test files
|
||||||
'test/unit_frontend/es/**/*.js'
|
'test/unit_frontend/es/**/*.js'
|
||||||
],
|
],
|
||||||
|
middleware: ['fake-img'],
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
// Run ES test files through webpack (which will then include source
|
// Run ES test files through webpack (which will then include source
|
||||||
// files in bundle)
|
// files in bundle)
|
||||||
|
@ -54,8 +55,21 @@ module.exports = function (config) {
|
||||||
require('karma-mocha'),
|
require('karma-mocha'),
|
||||||
require('karma-chai-sinon'),
|
require('karma-chai-sinon'),
|
||||||
require('karma-webpack'),
|
require('karma-webpack'),
|
||||||
require('karma-mocha-reporter')
|
require('karma-mocha-reporter'),
|
||||||
|
{ 'middleware:fake-img': ['factory', fakeImgMiddlewareFactory] }
|
||||||
],
|
],
|
||||||
reporters: ['mocha']
|
reporters: ['mocha']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle fake images
|
||||||
|
*/
|
||||||
|
function fakeImgMiddlewareFactory () {
|
||||||
|
return function (req, res, next) {
|
||||||
|
if (req.originalUrl.startsWith('/fake/')) {
|
||||||
|
return res.end('fake img response')
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue