Skip to content

Commit

Permalink
#35 Measure Code Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg-rade committed Sep 27, 2019
1 parent 275df7d commit 24ab4a0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 87 deletions.
27 changes: 8 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-serialization:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:${frontendPluginVersion}"
// classpath "net.devrieze:xmlutil-serialization:0.12.0.0"
}
}

Expand All @@ -28,7 +27,6 @@ if (production) {
}
apply plugin: 'org.jetbrains.kotlin.frontend'
apply plugin: 'kotlinx-serialization'
//apply plugin: 'xmlutil-serialization-js'

repositories {
maven { url = "http://bintray.com/" }
Expand Down Expand Up @@ -58,14 +56,13 @@ dependencies {
compile "pl.treksoft:kvision-moment:${kvisionVersion}"
compile "pl.treksoft:kvision-tabulator:${kvisionVersion}"
testCompile "org.jetbrains.kotlin:kotlin-test-js:${kotlinVersion}"
// compile "net.devrieze:xmlutil-serialization:0.12.0.0"
}

kotlinFrontend {
sourceMaps = true // CHANGE HERE
sourceMaps = true
webpackBundle {
bundleName = "main"
sourceMapEnabled = false // CHANGE HERE (it must be false!)
sourceMapEnabled = false
contentPath = file('src/main/web')
mode = production ? "production" : "development"
}
Expand All @@ -78,7 +75,7 @@ compileKotlin2Js {
outputFile = "$project.buildDir.path/js/${project.name}.js"
sourceMap = !production
sourceMapEmbedSources = "always"
moduleKind = 'umd'
moduleKind = 'commonjs'
}
}

Expand All @@ -88,25 +85,17 @@ compileTestKotlin2Js {
outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js"
sourceMap = !production
sourceMapEmbedSources = "always"
moduleKind = 'umd'
moduleKind = 'commonjs'
}
}

task pot(type: GruntTask) {
args = ["pot"]
}

task po2json(type: GruntTask) {
args = ["default"]
inputs.dir(file('translation'))
outputs.dir(file('build/js'))
outputs.dir(file('build/kotlin-js-min/main'))
}

pot.dependsOn 'installGrunt'
pot.dependsOn 'npmInstall'
po2json.dependsOn 'installGrunt'
po2json.dependsOn 'npmInstall'


task copyResources(type: Copy) {
from "src/main/resources"
Expand Down Expand Up @@ -147,8 +136,8 @@ afterEvaluate {
tasks.getByName("copyResourcesForDce") { dependsOn(runDceKotlinJs) }
}
tasks.getByName("webpack-bundle") {
dependsOn(/*po2json,*/ copyResources, copyResourcesForDce)
dependsOn(copyResources, copyResourcesForDce)
}
tasks.getByName("webpack-run") { dependsOn(/*po2json,*/ copyResources) }
tasks.getByName("karma-start") { dependsOn(/*po2json,*/ copyResources) }
tasks.getByName("webpack-run") { dependsOn(copyResources) }
tasks.getByName("karma-start") { dependsOn(copyResources) }
}
4 changes: 0 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ kotlinVersion=1.3.50
kvisionVersion=1.0.0
serializationVersion=0.11.0
frontendPluginVersion=0.0.45
kotlin.incremental.js=false
#kotlin.parallel.tasks.in.project=true
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.login=a3d5c3d3fd7ec307158740001e8c04c3f437ff93
94 changes: 30 additions & 64 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,34 @@
// see https://github.com/mkraynov/kfsad/blob/master/karma.conf.js
// Example: see https://github.com/mkraynov/kfsad/blob/master/karma.conf.js
// Doc: see http://karma-runner.github.io/4.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
// all plugins have to be installed before via
// npm install <plugin> --save-dev
plugins: [
'karma-webpack',
'karma-browserify',
'karma-jasmine',
'karma-mocha',
'karma-mocha-reporter',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-coverage'],
frameworks: ['mocha'],
files: [
'build/js-tests/kroviz-tests.js'
],
exclude: [],
preprocessors: {
'build/**/*_test.js': ['webpack']
},
// webpack: require('./webpack.karma'),
webpack: {
entry: './build/js-tests/kroviz-tests.js',
output: {
filename: 'bundle.js'
}
},
webpackMiddleware: {
noInfo: true
},
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
// https://github.com/karma-runner/karma-chrome-launcher/issues/158#issuecomment-339265457
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
singleRun: true,
concurrency: Infinity,
client: {
mocha: {
timeout: 6000
}
}
files: ['./build/**/*.js'],
excludes: ['./**/*.css'],
preprocessors: {
// 'build/**/*_test.js': ['webpack']
},
frameworks: ['jasmine'],
plugins: [
require('karma-chrome-launcher'),
require('karma-coverage-istanbul-reporter'),
require('istanbul-instrumenter-loader'),
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
require('karma-webpack')
],
reporters: ['coverage-istanbul'],
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
// if using webpack and pre-loaders, work around webpack breaking the source path
fixWebpackSourcePaths: true
},
browsers: ['ChromeHeadless'],

/* plugins: [
'karma-browserify',
'karma-mocha',
'karma-mocha-reporter',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-coverage'],
browserify: ({
entries: ['./build/js/kroviz.js'], */
// noParse: ['./node_modules_imported/**/*js']
// }),
})
// logLevel: config.LOG_DEBUG,
autoWatch: true,
singleRun: true,
concurrency: Infinity,
color: false
}
)
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"dependencies": {
"default-passive-events": "^1.0.10",
"grunt-cli": "^1.3.2",
"istanbul-instrumenter-loader": "^3.0.1",
"karma-coverage-istanbul-reporter": "^2.1.0",
"karma-jasmine-html-reporter": "^1.4.2",
"kotlinx-serialization-runtime-js": "^0.5.0",
"progress": "^2.0.3",
Expand Down

0 comments on commit 24ab4a0

Please sign in to comment.