I'm currently trying to run Karate tests on a Node project using this library: https://github.com/karatelabs/karate-npm . My script on package json looks like:
{
"test_karate" : "MY_VARIABLE=STG node karate/test.js karate/tests/WHATEVER_FEATURE.feature"
}
So, based on the value of "MY_VARIABLE" I would like to determine the host for the url on the karate-config.js, but I haven't been able to retrieve the value inside the karate-config.js file.
I have tried: 1.- Create a side script that returns process.env.MY_VARIABLE and trigger it using karate.exec() but it returns undefined. 2.- Passing it as part of the cli "-Dkarate.MY_VARIABLE=STG" or other syntax but it can't be retrieve inside karate-config.js file.
I know Karate it's usually use with maven and Java, but I'm currently using node, I'm expecting to be able to do something like this:
karate-config.js:
let env = process.env.MY_VARIABLE
if(env== "STG"){
// do something
}else{
// do something
}