I would like to use dynamic import in my playwright scripts to load a certain data file depending on the environment parameter.
Something like this:
let data: Promise<username: string, password: string>;
data = import("@test-data/user_data.json");
test("my env test", async => {
(await data).username;
})
I think @test-data/user_data.json should be defined in the tsconfig.json file like this:
{
"compilerOptions": {
"target": "es6",
"strict": true,
"module": "commonjs",
"sourceMap": true,
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
"@test-data/*": [
"stage/users/*"
]
}
}
}
Is there a way I can dynamically specify here the stage in the path stage/users/* based on my environment (which I could read from the process.env variable specified while running the test)?
Thanks!