https://kotlinlang.org logo
#compose-web
Title
# compose-web
g

Gerardo Rodriguez

01/29/2023, 7:52 AM
Does anyone know if it’s possible to use Selenium/Js to have selenium tests in
jsTest
only and avoid having Selenium java tests in the
jvmTest
?
👌 1
Do you have by any chance an example on how to set it up? 😄 @Big Chungus
b

Big Chungus

01/29/2023, 2:14 PM
You set it up the same as you would in npm project - add dependencies, write tests and possibly configure webpack. I've never used selenium js myself, but the point is that jsTest and jvmTest have no overlap whatsoever si whatever you do in jsTest has no effect on jvmTest
g

Gerardo Rodriguez

01/29/2023, 2:39 PM
I’ll give it a try. Thanks!
Wasn’t able to 😞 I keep getting either
Error: Cannot find module 'fs'
or
Error: Cannot find module 'http'
When I try to import the module
Copy code
@JsModule("selenium-webdriver/chrome")
@JsNonModule
external val chromeDriver: dynamic

@JsModule("selenium-webdriver")
@JsNonModule
external val selenium: dynamic
Copy code
class Test {

    @Test
    fun test() {
        chromeDriver //For this I require 'fs' module
        selenium //For this I require 'http' module
    }

}
Gradle side:
Copy code
val jsTest by getting {
            dependencies {
                implementation(kotlin("test-js"))
                implementation(compose.web.testUtils)

                val seleniumVersion = "4.8.0"
                implementation(npm("selenium-webdriver", seleniumVersion))
            }
        }
I’m not a web developer so not sure why webpack complains those modules are not found
b

Big Chungus

01/29/2023, 4:06 PM
Ah, looks like you're trying to use a package built to run on node with browser() js flavour.
To get fs and friends working you need nodejs()
47 Views