# multiplatform


11/08/2018, 9:12 AM
I have yet another early attempt at a Kotlin multiplatform library (JVM, JS, macos since they are the default from Intellij’s multiplatform library (current) template) up on Github at . The important feature for this piece of work is code coverage. Only the JVM has support for code coverage (via Jacoco) via the Gradle task jacocoJVMTestReport. This effort shows 100% covered code implemented using clean code/clean architecture approaches. Note that only JVM and macos tests run. Not sure what the issue with JS is yet. That issue and both Android and iOS support will be addressed next.

Jurriaan Mous

11/08/2018, 9:26 AM
Nice! About JS tests, the default template does not supply a JS test runner. You need to add that yourself. There are some examples out there for different runners. I use this script to add karma to my multiplatform project:
Copy code
// Gradle script to setup a JS multi-platform project
ext.setupJS = { runTests ->
    apply {

    kotlin {
        targets {
            fromPreset(presets.js, 'js')
        sourceSets {
            jsMain {
                dependencies {
                    implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'

    node {
        nodeModulesDir = file("${project.rootDir}/.nodeTest")

    [compileKotlinJs, compileTestKotlinJs]*.configure {
        kotlinOptions.moduleKind = "commonjs"
        kotlinOptions.sourceMap = true

    if (runTests == null || runTests == true) {
        task installMocha(type: NpmTask) {
            args = ['install', 'mocha']

        afterEvaluate {
            // Directory for all js test dependencies
            def testDir = "${buildDir}/jsTest"
            def projectName = name

            // Copy test files
            task copyJsTestOutput(type: Copy, dependsOn: [compileTestKotlinJs]) {
                from compileTestKotlinJs.outputFile.parentFile.path
                include "*.js"
                include "*"
                into testDir

            // Copy all to be tested code and dependencies
            task copyJsMainOutputAndDependencies(type: Copy, dependsOn: compileKotlinJs) {
                from compileKotlinJs.destinationDir
                configurations.jsTestCompileClasspath.each {
                    from(zipTree(it.absolutePath).matching { include '*'; include '*.js' })


            // Use mocha as the test runner
            task runMocha(type: NodeTask, dependsOn: [copyJsMainOutputAndDependencies, copyJsTestOutput, installMocha]) {
                script = file("../.nodeTest/node_modules/mocha/bin/mocha")
                args = ["${testDir}/${projectName}_test.js"]

            // Let mocha run when test is run in JS target
            jsTest.dependsOn runMocha
And in project:
Copy code
apply {
👍 1


11/08/2018, 9:40 AM
This is awesome! I've been looking for a good solution to coverage!
🙂 1


11/08/2018, 3:53 PM
What is the argus project?


11/10/2018, 1:06 PM
It is an attempt to normalize streaming video experience. As of today, streaming platforms like Netflix, Hulu, PSB, Amazon, etc. all have different ways of managing what you watch, which episode, wish lists, etc. Argus is an attempt to put a layer on top of each service and make life easier for those of us who cannot remember what shows we were watching, what network they were on, etc.
More importantly, Argus is the project I chose to leverage Kotlin’s unique approach to target multiple platforms with a common code base.
Especially to address code coverage issues.