2

As the title says I'm experiencing issues when trying to pass a config item to the feature file I call from callSingle() in karate-config.js. Everything works as expected if I only pass 1 parameter which is the path to the feature file. I tried copying the entire config from the example karate-config.js and yet was still getting the same error. Would appreciate any explanation.

karate-config.js:

function fn() {
  var env = karate.env; // get system property 'karate.env'
  karate.log('karate.env system property was:', env);
  if (!env) {
    env = 'kermit';
  }
    karate.log('karate.env system property was:', env);
  var config = {
    env: env,
    base_url: 'https://api.'+env+'.chdev.org',
    account_url: 'https://account.'+env+'.chdev.org'
  }

  var result = karate.callSingle('classpath:authorization/authorization.feature', config);
  karate.log(result);

  return config;
}

Error I'm getting:

16:48:10.548 [main] ERROR com.intuit.karate - evaluation of 'karate-config.js' failed: javascript function call failed: unexpected feature call arg type: class jdk.nashorn.internal.scripts.JO4
Exception in thread "main" java.lang.NullPointerException
    at com.intuit.karate.core.ScenarioExecutionUnit.init(ScenarioExecutionUnit.java:147)
    at com.intuit.karate.core.ScenarioExecutionUnit.run(ScenarioExecutionUnit.java:236)
    at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:164)
    at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:73)
    at com.intuit.karate.core.Engine.executeFeatureSync(Engine.java:109)
    at com.intuit.karate.IdeUtils.exec(IdeUtils.java:64)
    at cucumber.api.cli.Main.main(Main.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

In fact no matter what I pass as 2nd arg I always get a variation of class jdk.nashorn error.

Rzulfcut
  • 21
  • 3

2 Answers2

0

config} definitely looks like a typo to me.

Sorry but I think the best option for you is to follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • sorry, copy paste error mixed with me changing stuff on the fly, fixed the typo - there was no typo in the code. – Rzulfcut Jun 20 '19 at 07:33
  • I am away from my work machine for 10 days, I'll follow the submit an issue instructions when I come back, hoped there might be something obvious I am missing. As I said I copied the demo example from karate github and that also didn't work - no chance for typo there. – Rzulfcut Jun 20 '19 at 07:40
  • @Rzulfcut there's only one way now to convince me :P – Peter Thomas Jun 20 '19 at 10:00
0

MR Peter Thomas has confirmed the project I've sent to him as a github issue works as expected which proved it is an environmental issue. It was resolved by updating the maven and jdk8 to the latest releases.

Rzulfcut
  • 21
  • 3