Configuring proxy in karate-config.js get parse error

iamsleep

I have proxy settings for our testing, e.g.,

function() {                                                                                                                                                                                                                                            

    var config = { // base config JSON                                                                                                                                                                                                                  
        sslConfig: true,                                                                                                                                                                                                                                
        apiUrl: 'https://my-api.com',                                                                                                                                                                                                                   
        api2Url: 'https://my-api2.com',                                                                                                                                                                                                                 
        proxy:                                                                                                                                                                                                                                          
        {                                                                                                                                                                                                                                               
            uri: 'http://my-proxy.com:3128',
            nonProxyHosts:                                                                                                                                                                                                                              
            [                                                                                                                                                                                                                                           
                'my-api2.com',                                                                                                                                                                                                                          
            ]                                                                                                                                                                                                             
        }                                                                                                                                                                                                                                               
    };                                                                                                                                                                                                                                                  

    karate.configure('connectTimeout', 10001);                                                                                                                                                                                                          
    karate.configure('readTimeout', 10000);                                                                                                                                                                                                             
    karate.configure('proxy', config.proxy);                                                                                                                                                                                                            
    return config;                                                                                                                                                                                                                                      
}

And it works fine in 0.9.2, after upgrade to 0.9.3, I get parsing error message below and process hanging there

    13:47:45.639 | [ForkJoinPool-1-worker-1] | ERROR 

    failed function body: function() {

          var config = { // base config JSON
              sslConfig: true,
              apiUrl: 'https://my-api.com',
              api2Url: 'https://my-api2.com',
              proxy:
              {
                  uri: 'http://my-proxy.com:3128',
                  nonProxyHosts:
                  [
                      'my-api2.com',
                  ]
              }
          };

          karate.configure('connectTimeout', 10001);
          karate.configure('readTimeout', 10000);
          karate.configure('proxy', config.proxy);
          return config;
      }

    13:47:45.646 | [ForkJoinPool-1-worker-1] | ERROR 

    evaluation of 'karate-config.js' failed: javascript function call failed: net.minidev.json.JSONArray cannot be cast to jdk.nashorn.api.scripting.ScriptObjectMirror

And I try to remove the key nonProxyHosts, it works again. Can anyone suggest the solution for this issue?

Peter Thomas

Yes, this is a bug that was introduced in 0.9.3 - we opened a ticket here and it is fixed (in the develop branch) https://github.com/intuit/karate/issues/802

If you can build this from source and confirm that it works for you, we can expedite releasing a patch version.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Karate karate-config.js not a js function

Caused by: com.intuit.karate.exception.KarateException: ReferenceError: "XMLHttpRequest" is not defined Exception in Karate config js file

Pass Json to karate-config.js file

set Karate-config.js values in feature

How to use karate.callSingle() in karate-config.js?

How to use karate.callSingle() in my karate-config.js?

'not found' error with proxy config in Angular 6

Use karate-config.js with standalone jar?

How to set retry untill in karate-config.js

[karate][standalone v0.9.1] Error : could not find or read file: file:xxx/yyy/zzz/./karate-config.js

Is it possible to have two baseUrls in the karate-config.js?

Karate - How to use karate-config.js variables in java file?

When karate-config.js fails it prints error for each feature

How to pass multiple parameters to callSingle karate on karate-config.js

How to read variables in karate-config.js from Java

How to setup Proxy in Karate config file

Karate get response is giving xpath not found error

How to configure karate afterScenario in karate-config.js file

How to define or use karate-config.js in standalone jar?

Nuxt - Fonts are not preloaded in <head> despite configuring in nuxt.config.js

"Parse Error: Header overflow" During Node.js GET Request

Use a js file inside karate-config.js

Why proxy in vue.config.js 404

Karate Automation Test Framework - need access to list of features included in run from karate-config.js

karate.callSingle not found .feature file in karate-config.js

How to hide karate-config.js data coming in cucumber report?

Defining two o more functions in karate-config.js

Cookies aren't applying from karate-config.js

how to set highlightDuration in karate-config.js