2016-03-29 00:29:49 +02:00
|
|
|
// karma.conf.js - the config file for karma, which runs our tests.
|
|
|
|
|
2016-03-24 23:59:01 +01:00
|
|
|
var webpack = require('webpack');
|
|
|
|
var path = require('path');
|
|
|
|
|
2016-03-28 18:36:22 +02:00
|
|
|
/*
|
2016-03-29 00:29:49 +02:00
|
|
|
* We use webpack to build our tests. It's a pain to have to wait for webpack
|
|
|
|
* to build everything; however it's the easiest way to load our dependencies
|
|
|
|
* from node_modules.
|
2016-03-28 18:47:06 +02:00
|
|
|
*
|
|
|
|
* TODO:
|
2016-03-29 00:35:36 +02:00
|
|
|
* - can we run one test at a time?
|
2016-03-28 18:36:22 +02:00
|
|
|
*/
|
2016-03-29 00:29:49 +02:00
|
|
|
|
|
|
|
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';
|
|
|
|
|
2016-03-24 23:59:01 +01:00
|
|
|
module.exports = function (config) {
|
|
|
|
config.set({
|
2016-03-28 18:36:22 +02:00
|
|
|
// frameworks to use
|
|
|
|
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
2016-03-24 23:59:01 +01:00
|
|
|
frameworks: ['mocha'],
|
2016-03-28 18:36:22 +02:00
|
|
|
|
|
|
|
// list of files / patterns to load in the browser
|
2016-03-24 23:59:01 +01:00
|
|
|
files: [
|
2016-03-28 23:59:34 +02:00
|
|
|
'test/tests.js',
|
|
|
|
],
|
|
|
|
|
|
|
|
// list of files to exclude
|
|
|
|
// (this doesn't work, and I don't know why - we still rerun the tests
|
|
|
|
// when lockfiles are created)
|
|
|
|
exclude: [
|
|
|
|
'**/.#*'
|
2016-03-24 23:59:01 +01:00
|
|
|
],
|
2016-03-28 18:36:22 +02:00
|
|
|
|
|
|
|
// preprocess matching files before serving them to the browser
|
|
|
|
// available preprocessors:
|
|
|
|
// https://npmjs.org/browse/keyword/karma-preprocessor
|
2016-03-24 23:59:01 +01:00
|
|
|
preprocessors: {
|
2016-03-28 18:36:22 +02:00
|
|
|
'test/tests.js': ['webpack', 'sourcemap']
|
2016-03-24 23:59:01 +01:00
|
|
|
},
|
2016-03-28 18:36:22 +02:00
|
|
|
|
|
|
|
// test results reporter to use
|
|
|
|
// possible values: 'dots', 'progress'
|
|
|
|
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
2016-03-29 00:35:36 +02:00
|
|
|
reporters: ['progress', 'junit'],
|
2016-03-28 18:36:22 +02:00
|
|
|
|
|
|
|
// web server port
|
|
|
|
port: 9876,
|
|
|
|
|
|
|
|
// enable / disable colors in the output (reporters and logs)
|
|
|
|
colors: true,
|
|
|
|
|
|
|
|
// level of logging
|
|
|
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
|
|
|
|
// config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
|
|
logLevel: config.LOG_INFO,
|
|
|
|
|
|
|
|
// enable / disable watching file and executing tests whenever any file
|
|
|
|
// changes
|
|
|
|
autoWatch: true,
|
|
|
|
|
|
|
|
// start these browsers
|
|
|
|
// available browser launchers:
|
|
|
|
// https://npmjs.org/browse/keyword/karma-launcher
|
|
|
|
browsers: [
|
|
|
|
'Chrome',
|
|
|
|
//'PhantomJS',
|
|
|
|
],
|
|
|
|
|
|
|
|
// Continuous Integration mode
|
|
|
|
// if true, Karma captures browsers, runs the tests and exits
|
|
|
|
singleRun: true,
|
|
|
|
|
|
|
|
// Concurrency level
|
|
|
|
// how many browser should be started simultaneous
|
|
|
|
concurrency: Infinity,
|
|
|
|
|
2016-03-29 00:35:36 +02:00
|
|
|
junitReporter: {
|
|
|
|
outputDir: 'karma-reports',
|
|
|
|
},
|
|
|
|
|
2016-03-24 23:59:01 +01:00
|
|
|
webpack: {
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{ test: /\.json$/, loader: "json" },
|
2016-03-28 23:59:34 +02:00
|
|
|
{
|
|
|
|
// disable 'require' and 'define' for sinon, per
|
|
|
|
// https://github.com/webpack/webpack/issues/304#issuecomment-170883329
|
|
|
|
test: /sinon\/pkg\/sinon\.js/,
|
|
|
|
// TODO: use 'query'?
|
|
|
|
loader: 'imports?define=>false,require=>false',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/, loader: "babel",
|
|
|
|
include: [path.resolve('./src'),
|
|
|
|
path.resolve('./test'),
|
|
|
|
],
|
|
|
|
query: {
|
|
|
|
presets: ['react', 'es2015']
|
|
|
|
},
|
2016-03-28 18:36:22 +02:00
|
|
|
},
|
2016-03-24 23:59:01 +01:00
|
|
|
],
|
|
|
|
noParse: [
|
|
|
|
// don't parse the languages within highlight.js. They
|
|
|
|
// cause stack overflows
|
|
|
|
// (https://github.com/webpack/webpack/issues/1721), and
|
|
|
|
// there is no need for webpack to parse them - they can
|
|
|
|
// just be included as-is.
|
|
|
|
/highlight\.js\/lib\/languages/,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'matrix-react-sdk': path.resolve('src/index.js'),
|
2016-03-28 23:59:34 +02:00
|
|
|
'sinon': 'sinon/pkg/sinon.js',
|
2016-03-24 23:59:01 +01:00
|
|
|
},
|
|
|
|
},
|
2016-03-28 19:19:37 +02:00
|
|
|
devtool: 'inline-source-map',
|
2016-03-24 23:59:01 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|