https://kotlinlang.org logo
#javascript
Title
# javascript
b

Bernhard

03/15/2024, 9:31 PM
how do I import/load a JSON file from the resources/ folder at runtime and in a test? code will run in a browser and tests have currently no special runtime set up so I guess it's using the default
1
t

turansky

03/16/2024, 9:20 AM
Do you want to include it in bundle?
b

Bernhard

03/16/2024, 9:20 AM
ideally both: load it from the server and/or include it in the bundle; trying to figure things out right now
including it in the bundle uses a require right? unsure about the path though
t

turansky

03/16/2024, 9:21 AM
For loading you can use
fetch
For including inside
import
function
b

Bernhard

03/16/2024, 9:22 AM
inside tests, what paths/methods do you use there?
t

turansky

03/16/2024, 9:26 AM
I use relative path from
resources
folder
Methods -
import
or
require
For valid path resolving you will need additional Webpack configuration - it's generated in my case
You can check generated configuration here (after build configuration folder will be created)
b

Bernhard

03/16/2024, 9:31 AM
thank you!