mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #394 from sharelatex/as-karma-fake-img
Handle fake images in karma, preventing 404 warnings
This commit is contained in:
commit
458506ff66
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