Search code examples
karate

IDE says "Unresolved variable or type java" for java interop


I want to use the uuid function found here

* def uuid = function() { return java.util.UUID.randomUUID() + ''}

but the IDE gives an error on java - Unresolved variable or type java.

I also referred to the docs and added the getDate function:

  """
  function() {
      var SimpleDateFormat = Java.type('java.text.SimpleDateFormat');
      var sdf = new SimpleDateFormat('yyyy/MM/dd');
      var date = new java.util.Date();
      return sdf.format(date);
    }
  """

and the Java.type has the same error.IntelliJ error


Solution

  • Yes the IntelliJ plugin has a few limitations for JS and Java interop - and for now, you can disable warnings for JS unresolved variables. This is something that is on the roadmap and will be fixed in the future. Tests will run fine as long as the syntax is correct.