I'm trying to test code that uses `kotlin.browser....
# javascript
j
I'm trying to test code that uses
kotlin.browser.window.setInterval
I get the following error:
ReferenceError: window is not defined
I thought I was only targeting browser
Copy code
js("browser") {
        browser {}
    }
and that those tests are executed by karma in chrome. Am I wrong? Is there more to only targeting browsers and getting the tests to run in the headless browser?
t
Kotlin
1.3.72
?
Do you have dependency on
stdlib-js
?
j
yes to both
t
And
kotlin("test-js")
in test dependencies?
j
yeah that one too
t
Do you use static import for
setInterval?
j
no
t
Copy code
// Try 
js {
    browser ()
}

// instead of
js("browser") {
    browser {}
}
j
oh hey that's different. at least it looks like that is actually running in chrome. new error
Error: Uncaught SyntaxError: Unexpected identifier (<http://localhost:9876/context.html:1>)
t
CI or local run?
j
local
t
Clean run required
Usually previous fails corrupt next runs
Copy code
./gradlew clean
./gradlew --stop
j
hmm still getting that error but it's only for a few tests that I'll have to debug. thanks for the help. much appreciated.
🙂 1