Reputation: 11
#! /usr/bin/env node
const karate = require("@karatelabs/karate");
karate.version = "1.3.0";
let env = process.env["KARATE_ENV"];
karate.properties["env"] = env;
console.log("karate.env: ", env);
function fn() {
let configData = {};
if (env == "dev") {
configData.baseURL = "http://localhost:3010";
configData.testData = "test/dev/";
configData.utilityPath = "utility/";
} else if (env == "qa") {
configData.baseURL = "http://localhost:3010";
configData.testData = "test/qa/";
configData.utilityPath = "utility/";
}
return configData;
}
// Execute the function and store the config
var config = fn();
// Run the tests in the specified folder
karate.exec();
this is my karate-config.js file. I want to access this config data in my feature file. I tried multiple options but it didn't worked
I tried passing it in karate.env, karate.config also tried to add it in karate.properties but all failed to get data in feature file.
Upvotes: 1
Views: 55
Reputation: 58128
Refer to the docs: https://github.com/karatelabs/karate-npm#karate-configjs
Put a karate.log()
statement in your karate-config.js
and make sure it is appearing on the console.
Then just refer to the standard Karate docs for everything else.
Upvotes: 0