Is there a way to run Kotest with a JS-only projec...
# kotest
j
Is there a way to run Kotest with a JS-only project? I can only find MPP and JVM setups.
s
It should work the same way
You need engine-js on your classpath
j
I know nothing about kotest, can you elaborate?
s
you'd just setup the build as described in the quick start guide
I guess the guide isn't amazing. Basically you need kotest-framework-engine-js dependency in your test dependencies and then you can just run jsCheck and it should just work
j
If I include kotest-runner I get build errors. The default Kotlin-wizard-created test setup (which uses Karma, whatever that is). If just add testImplementation(kotest-framework-engine), IDEA can resolve the WordSpec and such references in the IDE but actually running the test task tells me "Unresolved reference: WordSpec"
s
you don't need runner for pure JS projects, that's only for jvm
I take it you're on 4.2.5
testImplementation("io.kotestkotest framework engine js4.2.5")
you can try adding
testImplementation("io.kotest:kotest-framework-api-js:4.2.5")
as well
your tests should be in jsTest
j
Adding API fixed those build errors. There is no "jsTest", just "test" and "browserTest" tasks (they existed before adding kotest, but seems to use it now... isn't jsTest something that only exists in MPP ?).
Seems I have some Chrome issues that I may have to fix first.
As an aside, which spec is advised? Seems most examples use WordSpec
s
I would say most people use fun spec or string spec
It doesn't matter, whatever you feel most comfortable with. DescribeSpec is the one that looks like JS test frameworks, so maybe use that if this is a js project.
j
Chrome fixed. I'm still missing
io.kotest.matchers
at runtime
s
different dependency
kotest-assertions-core-js
j
Thanks! Seems I'm up and running. For a pure Kotlin/JS project generated from IDEA (Gradle -> Kotlin/JS -> +Kotlin DSL) with the automatic Karma/ChromeHeadless setup all you have to do is add this:
Copy code
testImplementation("io.kotest:kotest-framework-engine-js:4.2.5")
    testImplementation("io.kotest:kotest-framework-api-js:4.2.5")
    testImplementation("io.kotest:kotest-assertions-core-js:4.2.5")
    testImplementation("io.kotest:kotest-property-js:4.2.5")
And the task name is just
:test
or
:browserTest
Might be one for the quickstart. Thanks again for the help.
s
you don't need the prop test actually unless you're using property testing
I'll update the quickstart as well
👍 1