chore: 🛠️ sharing karma configurations
This commit is contained in:
104
configs/karma-config.js
Normal file
104
configs/karma-config.js
Normal file
@ -0,0 +1,104 @@
|
||||
const cpuCount = require('os').cpus().length
|
||||
const es6Transform = require('karma-typescript-es6-transform')
|
||||
|
||||
module.exports = function (config, base, karmaTypescriptConfig) {
|
||||
const common = {
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '.',
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [],
|
||||
|
||||
frameworks: ['jasmine', 'karma-typescript'],
|
||||
|
||||
preprocessors: {
|
||||
'**/*.ts': ['karma-typescript'],
|
||||
},
|
||||
|
||||
reporters: ['spec', 'karma-typescript'],
|
||||
|
||||
browsers: [process.env.CI ? 'ChromeHeadless' : 'Chrome'],
|
||||
|
||||
customLaunchers: {
|
||||
ChromeHeadless: {
|
||||
base: 'Chrome',
|
||||
flags: [
|
||||
'--headless',
|
||||
'--no-sandbox',
|
||||
'--disable-gpu',
|
||||
'--disable-translate',
|
||||
'--disable-extensions',
|
||||
'--remote-debugging-port=9222',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
client: {
|
||||
jasmine: {
|
||||
random: false,
|
||||
},
|
||||
},
|
||||
|
||||
// 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: false,
|
||||
|
||||
// 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: cpuCount || Infinity,
|
||||
}
|
||||
|
||||
config.set(
|
||||
Object.assign(common, base, {
|
||||
karmaTypescriptConfig: Object.assign(
|
||||
{
|
||||
tsconfig: './tsconfig.json',
|
||||
bundlerOptions: {
|
||||
sourceMap: true,
|
||||
transforms: [
|
||||
es6Transform({
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
chrome: '60',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
coverageOptions: {
|
||||
instrumentation: true,
|
||||
exclude: /\.test|spec\.ts$/,
|
||||
},
|
||||
reports: {
|
||||
html: 'test/coverage',
|
||||
lcovonly: {
|
||||
directory: 'test/coverage',
|
||||
filename: 'lcov.info',
|
||||
subdirectory: './',
|
||||
},
|
||||
'text-summary': '',
|
||||
},
|
||||
},
|
||||
karmaTypescriptConfig,
|
||||
),
|
||||
}),
|
||||
)
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.13.10",
|
||||
"@babel/preset-env": "^7.13.10",
|
||||
"@types/jasmine": "^3.6.2",
|
||||
"@types/sinon": "^9.0.0",
|
||||
"coveralls": "^3.1.0",
|
||||
@ -10,7 +12,7 @@
|
||||
"karma-jasmine": "^4.0.1",
|
||||
"karma-spec-reporter": "^0.0.32",
|
||||
"karma-typescript": "^5.2.0",
|
||||
"karma-typescript-es6-transform": "^5.1.0",
|
||||
"karma-typescript-es6-transform": "^5.5.0",
|
||||
"sinon": "^9.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,70 +1,11 @@
|
||||
const es6transform = require('karma-typescript-es6-transform')
|
||||
|
||||
module.exports = (config) => {
|
||||
config.set({
|
||||
frameworks: ['jasmine', 'karma-typescript'],
|
||||
files: [{ pattern: 'src/**/*.ts' }],
|
||||
preprocessors: {
|
||||
'**/*.ts': ['karma-typescript'],
|
||||
module.exports = (config) =>
|
||||
require('../../configs/karma-config.js')(
|
||||
config,
|
||||
{
|
||||
files: [{ pattern: 'src/**/*.ts' }],
|
||||
logLevel: config.LOG_DEBUG,
|
||||
},
|
||||
reporters: ['spec', 'karma-typescript'],
|
||||
browsers: [process.env.CI ? 'ChromeHeadless' : 'Chrome'],
|
||||
customLaunchers: {
|
||||
ChromeHeadless: {
|
||||
base: 'Chrome',
|
||||
flags: [
|
||||
'--headless',
|
||||
'--no-sandbox',
|
||||
'--disable-gpu',
|
||||
'--disable-translate',
|
||||
'--disable-extensions',
|
||||
'--remote-debugging-port=9222',
|
||||
],
|
||||
},
|
||||
},
|
||||
karmaTypescriptConfig: {
|
||||
tsconfig: './tsconfig.json',
|
||||
{
|
||||
include: ['./src/**/*.ts', '../../node_modules/csstype/**/*'],
|
||||
bundlerOptions: {
|
||||
sourceMap: true,
|
||||
transforms: [
|
||||
es6transform({
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
coverageOptions: {
|
||||
instrumentation: true,
|
||||
exclude: /\.test\.ts$/,
|
||||
},
|
||||
reports: {
|
||||
html: 'test/coverage',
|
||||
lcovonly: {
|
||||
directory: 'test/coverage',
|
||||
filename: 'lcov.info',
|
||||
subdirectory: './',
|
||||
},
|
||||
'text-summary': '',
|
||||
},
|
||||
},
|
||||
client: {
|
||||
jasmine: {
|
||||
random: false,
|
||||
},
|
||||
},
|
||||
port: 9876,
|
||||
colors: true,
|
||||
autoWatch: true,
|
||||
singleRun: true,
|
||||
concurrency: Infinity,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
@ -73,6 +73,8 @@
|
||||
"utility-types": "^3.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.13.10",
|
||||
"@babel/preset-env": "^7.13.10",
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||
"@rollup/plugin-replace": "^2.3.4",
|
||||
@ -108,7 +110,7 @@
|
||||
"karma-jasmine": "^4.0.1",
|
||||
"karma-spec-reporter": "^0.0.32",
|
||||
"karma-typescript": "^5.2.0",
|
||||
"karma-typescript-es6-transform": "^5.1.0",
|
||||
"karma-typescript-es6-transform": "^5.5.0",
|
||||
"less": "^4.0.0",
|
||||
"lint-staged": "^10.5.3",
|
||||
"npm-run-all": "^4.1.5",
|
||||
|
Reference in New Issue
Block a user