I want to use absolute path in k6 js script file. Can someone please help in how to do this?
Instead of this
import {getAddCookieInfoPayLoad} from "../../../scripts/oAuth/addCookieInfoScript.js";
import {getQueryCookieInfoPayLoad} from "../../../scripts/oAuth/queryCookieInfoScript.js";
I want this:
import {getAddCookieInfoPayLoad} from "scripts/oAuth/addCookieInfoScript.js";
import {getQueryCookieInfoPayLoad} from "scripts/oAuth/queryCookieInfoScript.js";
import {getAddCookieInfoPayLoad} from "/absolute/path/to/scripts/oAuth/addCookieInfoScript.js";
and you can also import them with the file:// schema:
import {getAddCookieInfoPayLoad} from "file:///absolute/path/to/scripts/oAuth/addCookieInfoScript.js";
Though in general I find relative paths to be more usable and be more reliable when multiple people are working on the scripts, possibly across different OSes.
I would not expect this anytime soon, however, as changing the default behaviour would break backwards compatibility. The actual value other than cleaner-looking code is also, at least in my opinion, questionable.