Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions karma.fast.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
const argv = require('minimist')(process.argv.slice(2));
const components = argv.components !== true && argv.components;
const runCoverage = typeof argv.coverage !== 'undefined';
const runFirefox = typeof argv.firefox !== 'undefined';
const runChrome = typeof argv.chrome !== 'undefined';

const rootPath = __dirname;

module.exports = function (config) {
const plugins = ['karma-webpack', 'karma-jasmine', 'karma-sourcemap-loader'];
const launcher = [];

if (runCoverage) {
plugins.push('karma-coverage-istanbul-reporter');
}

if (runChrome) {
plugins.push('karma-chrome-launcher');
launcher.push('Chrome');
}

if (runFirefox) {
plugins.push('karma-firefox-launcher');
launcher.push('Firefox');
}

const tsConfig = {
compilerOptions: {
rootDir: rootPath,
declaration: false,
strict: false,
downlevelIteration: true,
transpileOnly: true, // Faster compilation - skip type checking
paths: {
'*': ['*', rootPath + '/packages/*'],
},
},
transpileOnly: true, // Enable faster transpilation
};

const rules = runCoverage
? [
{
test: /lib(\\|\/).*\.ts$/,
use: [
{ loader: '@jsdevtools/coverage-istanbul-loader' },
{
loader: 'ts-loader',
options: tsConfig,
},
],
},
{
test: /test(\\|\/).*\.ts$/,
loader: 'ts-loader',
options: tsConfig,
},
]
: [
{
test: /\.ts$/,
loader: 'ts-loader',
options: tsConfig,
},
];

const settings = {
basePath: '.',
plugins,
client: {
components: components,
clearContext: false,
captureConsole: true,
},
browsers: launcher,
files: ['tools/karma.test.all.js'],
frameworks: ['jasmine'],
preprocessors: {
'tools/karma.test.all.js': ['webpack', 'sourcemap'],
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
autoWatchBatchDelay: 300, // Batch file changes for better performance

// to avoid DISCONNECTED messages
browserDisconnectTimeout: 10000, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 60000, //default 10000
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true,
},

singleRun: true,
captureTimeout: 60000,

webpack: {
mode: 'development',
devtool: 'eval-source-map', // Faster than inline-source-map
module: {
rules,
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
modules: ['./packages', './node_modules'],
},
// Workaround karma-webpack issue https://github.com/ryanclark/karma-webpack/issues/493
// Got this solution from https://github.com/ryanclark/karma-webpack/issues/493#issuecomment-780411348
optimization: {
splitChunks: false,
removeAvailableModules: false, // Performance optimization
removeEmptyChunks: false, // Performance optimization
},
// Add filesystem caching for better performance
cache: {
type: 'filesystem',
cacheDirectory: require('path').join(rootPath, 'node_modules/.cache/webpack'),
},
stats: 'errors-warnings', // Reduce console output
},

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
};

if (runCoverage) {
settings.reporters = ['coverage-istanbul'];
settings.coverageIstanbulReporter = {
reports: ['html', 'lcovonly', 'text-summary'],
dir: './dist/deploy/coverage',
};
}

config.set(settings);
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"test": "node tools/build.js normalize & karma start --chrome",
"test:chrome": "node tools/build.js normalize & karma start --chrome",
"test:firefox": "node tools/build.js normalize & karma start --firefox",
"test:debug": "node tools/build.js normalize & karma start --no-single-run --chrome",
"test:debug-firefox": "node tools/build.js normalize & karma start --no-single-run --firefox",
"test:debug": "node tools/build.js normalize & karma start karma.fast.conf.js --no-single-run --chrome",
"test:fast": "node tools/build.js normalize & karma start karma.fast.conf.js --chrome",
"test:debug-firefox": "node tools/build.js normalize & karma start karma.fast.conf.js --no-single-run --firefox",
"test:coverage": "node tools/build.js normalize & karma start --coverage --firefox --chrome",
"publish": "node tools/build.js clean normalize buildcommonjs buildamd buildmjs dts pack packprod builddemo builddoc publish"
},
Expand Down
Loading