Import Karma settings instead of duplicating them

This commit is contained in:
Franck Royer 2022-01-14 12:57:29 +11:00
parent 8e591f22db
commit 99763322db
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 13 additions and 42 deletions

View File

@ -1,45 +1,16 @@
process.env.CHROME_BIN = require('puppeteer').executablePath();
// import settings from default config file
let properties = null;
const originalConfigFn = require('./karma.conf.js');
originalConfigFn({
set: function (arg) {
properties = arg;
},
});
// pass `--grep '[live data]'` to mocha to only run live data tests
properties.client.args = ['--grep', '[live data]]'];
// export settings
module.exports = function (config) {
config.set({
frameworks: ['mocha', 'karma-typescript'],
files: ['src/lib/**/*.ts', 'src/proto/**/*.ts'],
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
plugins: [
require('karma-mocha'),
require('karma-typescript'),
require('karma-chrome-launcher'),
],
reporters: ['progress', 'karma-typescript'],
browsers: ['ChromeHeadless'],
singleRun: true,
client: {
mocha: {
timeout: 6000, // Default is 2s
},
args: ['--grep', '[live data]]'],
},
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /^.*[^(node)]\.spec\.ts$/,
},
coverageOptions: {
instrumentation: false,
},
tsconfig: './tsconfig.json',
compilerOptions: {
noEmit: false,
},
include: {
mode: 'replace',
values: ['src/lib/**/*.ts', 'src/proto/**/*.ts'],
},
exclude: {
mode: 'replace',
values: ['node_modules/**'],
},
},
});
config.set(properties);
};