@Test
public void testKarateEnvAccessFromScript() {

    FeatureContext featureContext = FeatureContext.forEnv("baz");
    CallContext callContext = new CallContext(null, true);
    ScenarioContext ctx = new ScenarioContext(featureContext, callContext, null, null);
    Script.assign("foo", "function(){ return karate.env }", ctx);
    Script.assign("bar", "call foo", ctx);
    ScriptValue bar = ctx.vars.get("bar");
    assertEquals("baz", bar.getValue());
    // null
    featureContext = FeatureContext.forEnv();
    ctx = new ScenarioContext(featureContext, callContext, null, null);
    Script.assign("foo", "function(){ return karate.env }", ctx);
    Script.assign("bar", "call foo", ctx);
    bar = ctx.vars.get("bar");
    assertNull(bar.getValue());
}