Trying to convert the karma block (<https://github...
# gradle
n
Trying to convert the karma block (https://github.com/JetBrains/kotlin-examples/blob/48122d114162dc62c1ac45694aa515e36adefdbc/gradle/js-tests/karma/build.gradle#L35) from a Kotlin JS test example project to Kotlin DSL but end up with a error message saying that the karma task is not found.
l
Have you tried to specify the task class? Something like below.
Copy code
import org.jetbrains.kotlin.gradle.frontend.karma.KarmaExtension

configure<KarmaExtension> {
     frameworks = listOf("")
}
Note: I didn't tested it!
n
All tasks for the Karma plugin are defined in this file: https://github.com/craigburke/karma-gradle/blob/master/src/main/groovy/com/craigburke/gradle/KarmaPlugin.groovy . No karma task is defined in the file.
Not using the Kotlin JS front-end plugin.
l
Ah, ok. So instead of
KarmaExtension
it's
KarmaModuleExtension
.
Copy code
import com.craigburke.gradle.KarmaModuleExtension

configure<KarmaModuleExtension> {
}
👍 1
n
Managed to get further and it appears as though there is a issue with one of the Node modules (log4js):
Copy code
> Task :js:karmaRun FAILED
/home/napperley/idea_projects/webscene/webscene-core/js/node_modules/karma/node_modules/log4js/lib/layouts.js:69
  ) + util.format(...loggingEvent.data);
                  ^^^

SyntaxError: Unexpected token ...
😱 All Gradle issues seem to be resolved with the Karma plugin.
🎉 1
l
Did you fixed the spread operator error? Maybe it's the Node.js version.
n
No explicit versions are specified which might explain why the syntax error occurs.
Tried explicitly specifying the dependency (
dependencies(mutableListOf("mocha@v5.2.0"))
) however the same issue occurs.
If only there was a way to specify explicit versions for sub dependencies 🤔.
l
Applying the Node.js Gradle plugin and setting the Node.js version makes the error gone, but the tests failed. Can you try the code below, please?
Copy code
import com.moowork.gradle.node.NodeExtension

apply(plugin = "com.moowork.node")


configure<NodeExtension> {
    version = "10.0.0"
}
👍 1
n
Configuring the Node plugin via the NodeExtension works.
🎉 1