Hi I am struggling to access test resources from a...
# javascript
t
Hi I am struggling to access test resources from a JS browser test. I see the files alongside the test.js in the build folder. How can I access their content from within the test ? I tried using
window.fetch
but I get 404s
t
Do you need resources from
src/test/resources
for tests only?
t
Yes. I just solved it by adding the correct karma config. I added the following
test-resources
to
karma.config.d
Copy code
config.files.push({
    pattern: __dirname + "/kotlin/day*.txt",
    watched: false,
    included: false,
    served: true,
    nocache: false
});
config.set({
    "proxies": {
        "/test/resources/": __dirname + "/kotlin/"
    }
});
👍 2
t
What about
modules
configuration? You can simply add
src/test/kotlin
dir in
modules
t
(My solution above only works with
js(IR)
and not
js(LEGACY)
as resource files are not copied there)
@turansky are you talking about webpack config? I see no mention of modules in karma config.
t
AFAIK - karma config is also webpack config
In
karma.config.d/patch.js
:
Copy code
config.resolve.modules.unshift(
  // absolute path calculation
  "???/src/test/resources"
)