2018-02-22 17:45:31 +00:00
|
|
|
const path = require('path')
|
|
|
|
|
2018-02-12 16:48:09 +00:00
|
|
|
module.exports = function (config) {
|
|
|
|
config.set({
|
|
|
|
customLaunchers: {
|
|
|
|
ChromeCustom: {
|
|
|
|
base: 'ChromeHeadless',
|
|
|
|
// We must disable the Chrome sandbox when running Chrome inside Docker
|
|
|
|
// (Chrome's sandbox needs more permissions than Docker allows by
|
|
|
|
// default)
|
|
|
|
flags: ['--no-sandbox']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
browsers: ['ChromeCustom'],
|
2018-02-12 13:03:36 +00:00
|
|
|
files: [
|
|
|
|
'test/unit_frontend/js/bootstrap.js',
|
|
|
|
// Angular must be loaded before requirejs to set up angular global
|
|
|
|
'public/js/libs/angular-1.6.4.min.js',
|
|
|
|
'public/js/libs/angular-mocks.js',
|
|
|
|
'public/js/libs/jquery-1.11.1.min.js',
|
2018-04-04 12:19:21 +00:00
|
|
|
'public/js/libs/underscore-1.3.3.js',
|
2018-02-12 13:03:36 +00:00
|
|
|
// Set up requirejs
|
|
|
|
'test/unit_frontend/js/test-main.js',
|
|
|
|
// Include source & test files, but don't "include" them as requirejs
|
|
|
|
// handles this for us
|
|
|
|
{ pattern: 'public/js/**/*.js', included: false },
|
2018-02-22 17:45:31 +00:00
|
|
|
{ pattern: 'test/unit_frontend/js/**/*.js', included: false },
|
|
|
|
// Include ES test files
|
2018-03-22 14:15:08 +00:00
|
|
|
'test/unit_frontend/es/**/*.js',
|
2018-03-29 16:11:17 +00:00
|
|
|
'modules/**/test/unit_frontend/es/**/*.js',
|
|
|
|
// Include CSS (there is some in js/libs dir)
|
|
|
|
'public/stylesheets/**/*.css',
|
|
|
|
'public/js/libs/**/*.css'
|
2018-02-12 13:03:36 +00:00
|
|
|
],
|
2018-03-12 15:06:58 +00:00
|
|
|
middleware: ['fake-img'],
|
2018-02-22 17:45:31 +00:00
|
|
|
preprocessors: {
|
|
|
|
// Run ES test files through webpack (which will then include source
|
|
|
|
// files in bundle)
|
2018-03-26 10:12:45 +00:00
|
|
|
'test/unit_frontend/es/**/*.js': ['webpack'],
|
|
|
|
'modules/**/test/unit_frontend/es/**/*.js': ['webpack']
|
2018-02-22 17:45:31 +00:00
|
|
|
},
|
2018-02-12 16:48:09 +00:00
|
|
|
frameworks: ['requirejs', 'mocha', 'chai-sinon'],
|
2018-02-22 17:45:31 +00:00
|
|
|
// Configure webpack in the tests
|
|
|
|
webpack: {
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
// Alias Src in import pathnames to public/es
|
|
|
|
// Cuts down on the amount of ../../ etc
|
|
|
|
Src: path.join(__dirname, 'public/es/')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Configure the webpack dev server used to serve test files
|
|
|
|
webpackMiddleware: {
|
|
|
|
// Disable noisy CLI output
|
|
|
|
stats: 'errors-only'
|
|
|
|
},
|
2018-02-12 16:48:09 +00:00
|
|
|
plugins: [
|
2018-02-22 17:45:31 +00:00
|
|
|
require('karma-chrome-launcher'),
|
2018-02-12 16:48:09 +00:00
|
|
|
require('karma-requirejs'),
|
|
|
|
require('karma-mocha'),
|
|
|
|
require('karma-chai-sinon'),
|
2018-02-22 17:45:31 +00:00
|
|
|
require('karma-webpack'),
|
2018-03-12 15:06:58 +00:00
|
|
|
require('karma-mocha-reporter'),
|
|
|
|
{ 'middleware:fake-img': ['factory', fakeImgMiddlewareFactory] }
|
2018-02-12 16:48:09 +00:00
|
|
|
],
|
2018-02-22 14:04:22 +00:00
|
|
|
reporters: ['mocha']
|
2018-02-12 16:48:09 +00:00
|
|
|
});
|
|
|
|
}
|
2018-03-12 15:06:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle fake images
|
|
|
|
*/
|
|
|
|
function fakeImgMiddlewareFactory () {
|
|
|
|
return function (req, res, next) {
|
|
|
|
if (req.originalUrl.startsWith('/fake/')) {
|
|
|
|
return res.end('fake img response')
|
|
|
|
}
|
|
|
|
next()
|
|
|
|
}
|
2018-03-29 16:11:17 +00:00
|
|
|
}
|