Hi! I try to build a Kotlin-JS project using versi...
# gradle
a
Hi! I try to build a Kotlin-JS project using version 1.3.40-eap-67 according to this example https://youtrack.jetbrains.com/issue/KT-30528 . Test classes seem to not be compiled and the test isn't running. Where can I find an example of how to configure a test runner for this EAP version? Thank you.
g
Probably better to ask in #javascript, there are devs from Kotlin JS team
Or right in this issue
s
Hi @Alexander. You can try new test runner by adding this code to you
build.gradle
for multiplatform project:
Copy code
kotlin {
    js { 
        browser()
        nodejs()
    }
}
For single platform project:
Copy code
kotlin {
    target {
        browser()
        nodejs()
    }
}
browser()
will create
jsBrowserTest
task,
nodejs()
-
jsNodeTest
.
jsTest
will run both. Also you can configure some settings, for example browsers:
Copy code
kotlin {
   js {
      browser {
        testTask {
            useKarma {
                useChromeHeadless()
                useChrome()
                useChromeCanary()
                usePhantomJS()
                useFirefox()
                useOpera()
                useSafari()
                useIe()
            }
        }
      }
   }
}
I’ll post some more info in #javascript later.
By default tests not configured for compatibility.
g
Will those task be in dependencies for Gradle lifecycle tasks like test or check?
s
Yes, check will run them.
a
@snrostov Thanks for the reply. I tried your recommendation for a single platform project, and now I see the following error: internal/modules/cjs/loader.js:584 throw err; ^ Error: Cannot find module 'C:\Users\aliv0616\.gradle\yarn\yarn-v1.15.2\bin\yarn.js'
s
Probably it is https://youtrack.jetbrains.com/issue/KT-31645 It will be fixed in next EAP. Meanwhile, the workaround is to move everything from
C:\Users\aliv0616\.gradle\yarn\yarn-v1.15.2\yarn-v1.15.2
to
C:\Users\aliv0616\.gradle\yarn\yarn-v1.15.2
.