I can't for the life of me run a single test case ...
# kotest
e
I can't for the life of me run a single test case under K/JS. Should
--tests
work?
v
Only on class level: https://github.com/kotest/kotest/issues/1531#issuecomment-673753194 Unless something changed
thank you color 1
No, nothing changed, except that you can use a kotest-specific system property or env variable: https://kotest.io/docs/next/framework/conditional/conditional-tests-with-gradle.html#gradle-test-filtering
e
Both env and system props don't work with JS apparently. Also, the example is based on a JVM-only setup. Running
jsNodeTest
with whatever parameter doesn't seem to filter anything.
v
Hm, right, you asked about K/JS, sorry
But why do env variables "apparently" not work with JS?
I mean, the docs say it, but I wonder why
e
I can't find an example of someone running
jsTest
or
jsNodeTest
with a filter in the entire internet 🥲 And about that question: I really don't know. Probably they didn't want to split Node.js and browser implementations? Node is able to read env vars.
Guess I'll stick with kotlin-test until I somehow understand this part.
v
Inside one class you can at least use the focus prefix to skip the other test cases
e
The problem is I have hundreds of test cases in other classes that would be executed anyway
I very often focus on a single test case for a long time, and I need a quick feedback cycle
m
The only working approach I've found so far with mocha and gradle and kotest for filtering tests is to conditionally compile the test classes in build.gradle.kts. I've tried many things. We ran into an issue where running more than 14-ish test suites/test-classes with mocha and global-jsdom causes all of our tests to hang, so we're working toward a solution to allow us to painlessly partition our tests into smaller sets. This approach at least allows our many tests to co-exist in intellij while not hanging when actually running them.
Copy code
val excludeApplicationTests = project.findProperty("excludeApplicationTests") == "true"
val excludeMySpecificTests = project.findProperty("excludeMySpecificTests") == "true"

        compilations["test"].defaultSourceSet {
            if(excludeApplicationTests) {
                println("Excluding application tests from jsNodeTest")
                kotlin.exclude("com/example/config/LoadAppConfigUnitTest.kt")
                kotlin.exclude("com/example/error/ErrorContainerViewTest.kt")
                kotlin.exclude("com/example/http/FetchFromWebServiceUnitTest.kt")
            }
            if(excludeMySpecificTests) {
                println("Excluding mySpecific tests from jsNodeTest")
                kotlin.exclude("com/example/mySpecific/**/*Test.kt")
            }
        }