bpmn-js/test/config/karma.unit.js

107 lines
2.4 KiB
JavaScript
Raw Normal View History

var path = require('path');
var collectTranslations = process.env.COLLECT_TRANSLATIONS;
var singleStart = process.env.SINGLE_START;
2020-03-12 10:29:03 +00:00
var coverage = process.env.COVERAGE;
// configures browsers to run test against
// any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'IE', 'PhantomJS' ]
var browsers = (process.env.TEST_BROWSERS || 'ChromeHeadless').split(',');
2020-03-12 10:29:03 +00:00
// use puppeteer provided Chrome for testing
process.env.CHROME_BIN = require('puppeteer').executablePath();
var basePath = '../..';
var absoluteBasePath = path.resolve(path.join(__dirname, basePath));
2019-12-10 14:57:52 +00:00
var suite = coverage ? 'test/coverageBundle.js' : 'test/testBundle.js';
2014-03-11 14:54:36 +00:00
module.exports = function(karma) {
var config = {
2014-03-11 14:54:36 +00:00
2020-03-12 10:29:03 +00:00
basePath,
2014-03-11 14:54:36 +00:00
2015-10-09 23:35:41 +00:00
frameworks: [
'mocha',
'sinon-chai'
],
2014-03-11 14:54:36 +00:00
files: [
'node_modules/promise-polyfill/dist/polyfill.js',
suite
2014-03-11 14:54:36 +00:00
],
2014-03-11 14:54:36 +00:00
preprocessors: {
[ suite ]: [ 'webpack', 'env' ]
2014-03-11 14:54:36 +00:00
},
reporters: [ 'progress' ].concat(coverage ? 'coverage' : []),
2015-10-09 23:35:41 +00:00
coverageReporter: {
reporters: [
{ type: 'lcov', subdir: '.' }
]
},
2020-03-12 10:29:03 +00:00
browsers,
2014-03-11 14:54:36 +00:00
browserNoActivityTimeout: 30000,
2014-07-17 07:02:40 +00:00
singleRun: true,
autoWatch: false,
2014-03-11 14:54:36 +00:00
webpack: {
mode: 'development',
module: {
rules: [
{
test: /\.css|\.bpmn$/,
use: 'raw-loader'
}
].concat(coverage ?
{
test: /\.js$/,
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
},
include: /lib\.*/,
exclude: /node_modules/
} : []
)
},
resolve: {
mainFields: [
'dev:module',
'browser',
'module',
'main'
],
modules: [
'node_modules',
absoluteBasePath
]
},
devtool: 'eval-source-map'
2014-03-11 14:54:36 +00:00
}
};
if (collectTranslations) {
config.plugins = [].concat(config.plugins || ['karma-*'], require('./translation-reporter'));
config.reporters = [].concat(config.reporters || [], 'translation-reporter');
config.envPreprocessor = [].concat(config.envPreprocessor || [], 'COLLECT_TRANSLATIONS');
}
if (singleStart) {
config.browsers = [].concat(config.browsers, 'Debug');
config.envPreprocessor = [].concat(config.envPreprocessor || [], 'SINGLE_START');
}
karma.set(config);
2014-03-11 14:54:36 +00:00
};