looking at jsTest and kotlin test, it looks like f...
# javascript
b
looking at jsTest and kotlin test, it looks like files from jsMain/resources are not available in tests; how do I fix that? (probably related: I can't right click -> run test in intellij on my test class) (edited)
c
What code do you use to access the resources?
b
it's the script.js file which gets included as an es module in this case
Copy code
@file:JsModule("./script.js")

package at.fyayc

external fun add(a: Int, b: Int): Int
Copy code
export function add(a, b) {
    return a + b;
}
this file is not copied to the test resources folder it seems and "linking" fails
Uncaught Error: Cannot find module './script.js'
Module not found: Error: Can't resolve './script.js' in '/home/bernhard/dev/kotlinjs/build/js/packages/kotlinjs-test/kotlin'
I'm used to having the test resources folder being merged with the main one from Java/Kotlin
c
Yeah, you're right, I'm confused that I never noticed this earlier.
Long story short, resources don't get transitively included if you create a library module either. I created a Gradle plugin to fix that. I can add copying to test modules to it if you want.
b
I've read somewhere that the issue is not limited to js, someone had to fix it for iOS as well
or maybe that's only related to commonMain/resources
c
I don't do iOS development, so I couldn't tell you. However, I'm almost certain this isn't a problem for the JVM target, even if resources are declared in commonMain
b
thanks for the link, will try that; I suppose this is a bug that will be fixed at some point
c
Just to clarify, my plugin is to fix another similar problem with resources (resources not being available in downstream projects), it currently won't help with your problem (resources not being available in downstream source sets); I just linked it there because, if you want, I could include the fix for your problem as well
Also, if you do iOS development, and have the same problem, I could include the fix for that as well. I just haven't done so so far because I don't have a MacOS device to test it on 😅
b
not doing any iOS, just looking into JS right now (and JVM for my main job), but thanks
👍 1
t
Also option - configure Webpack modules. Like this plugin. You can check generated code for details.