yogi
05/13/2020, 9:47 AMsourceSet
.
I have configured a custom sourceSet
as below
js {
browser {}
nodejs {
useCommonJs()
}
val fooMain by compilations.creating {
nodejs {
useCommonJs()
}
defaultSourceSet {
dependencies {
api(kotlin("stdlib-js"))
implementation(npm("<some-dependency>","some-version"))
}
}
}
val fooTest by compilations.creating {
defaultSourceSet {
dependsOn(fooMain.defaultSourceSet)
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
// Some other config
sourceSets {
val jsMain by getting {
dependsOn(getByName("fooMain"))
// some more config
}
}
Now, the question is - How do I write a task that 'compiles and runs' the tests written in fooTest
. The [documentation](https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#running-tests) mentions that
For Kotlin/JS targets, add kotlin-test-js as a test dependency. At this point, test tasks for Kotlin/JS are created but do not run tests by default; they should be manually configured to run the tests with a JavaScript test framework.
Now, I believe that means configuring a KotlinJsTest
task that has useMocha()
configured.
However, I am unable to wire up such a task.
Can someone please help me out?
Also, apologies if this is present somewhere in the documentation - if it is, please direct me to it.
If it isn't , please direct me how I can add it once I have the answer 🙂Dominaezzz
05/13/2020, 2:18 PMval jsTest by getting {
dependsOn(getByName("fooTest"))
// some more config
}
yogi
05/14/2020, 4:16 AMfooTest
suite when we run the jsTest
suite (that way, jsTest
test suite runs the test cases for all js source sets). That is perfectly fine and I had got that working.
Is there a way to run only fooTest
test suite ?Dominaezzz
05/14/2020, 5:05 AMval jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}