You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
javascript templating with backtick symbol is not working on latest k6 releases. It is working up to release "grafana/k6:0.39.0-24-g0127a508", not anything after that
working fine with this command docker run -v ${PWD}:/test grafana/k6:0.39.0-24-g0127a508 run /test/test-1.js
not working with this docker run -v ${PWD}:/test grafana/k6:latest run /test/test-1.js or docker run -v ${PWD}:/test grafana/k6:0.39.0-25-ge2316a28 run /test/test-1.js
There is nothing wrong with the templating if you look carefully the problem is that BASE_URL isn't defined in conf_test-1.js which it isn't.
Previous to #2571 though all variables in the main module/script were globally available which was definitely a bug.
With the future addition of native ESM support this would break either way as ... well native modules don't expose their variables globally.
If you want to have access to a variable globally you should be using globalThis. So in this particular case changing to globalThis.BASE_URL = .... should fix it everywhere.
edit: I would also recommend that you use globalThis.BASE_URL wherever you use it. Otherwise, whoever reads the code after that might have really hard time figuring out where does this variable that isn't defined in this file is coming from.
Sorry for the breaking change, but this definitely was never documented or expected to work like that. If anything given that we say that we support ESM (not natively) it is expected to not work like that at all ;).
Brief summary
javascript templating with backtick symbol is not working on latest k6 releases. It is working up to release "grafana/k6:0.39.0-24-g0127a508", not anything after that
referenced the example from this url - https://k6.io/docs/test-types/load-testing
k6 version
0.39.0-25-ge2316a28
OS
linux ubuntu
Docker version and image (if applicable)
grafana/k6:0.39.0-25-ge2316a28
Steps to reproduce the problem
working fine with this command
docker run -v ${PWD}:/test grafana/k6:0.39.0-24-g0127a508 run /test/test-1.js
not working with this
docker run -v ${PWD}:/test grafana/k6:latest run /test/test-1.js
ordocker run -v ${PWD}:/test grafana/k6:0.39.0-25-ge2316a28 run /test/test-1.js
The text was updated successfully, but these errors were encountered: