I recently updated Karate from 1.2.0 and Java 8 to 1.4.1 and Java 11. Previously I had defined Javascript Functions and Java Types globally in karate-config.js, which were used frequently.
<code>config.isValidDateTime = read('classpath:validators/datetime-validator.js')
config.TimestampObject = Java.type('utils.Timestamp')
</code>
<code>config.isValidDateTime = read('classpath:validators/datetime-validator.js')
config.TimestampObject = Java.type('utils.Timestamp')
</code>
config.isValidDateTime = read('classpath:validators/datetime-validator.js')
config.TimestampObject = Java.type('utils.Timestamp')
For the Java Types, this no longer seems to work, I cannot execute the methods. When I call e.g.
<code>* set userProfile.firstName = UserMockHelper.getRandomFirstName();
</code>
<code>* set userProfile.firstName = UserMockHelper.getRandomFirstName();
</code>
* set userProfile.firstName = UserMockHelper.getRandomFirstName();
I receive the error message:
<code>org.graalvm.polyglot.PolyglotException: ReferenceError: "UserMockHelper" is not defined
</code>
<code>org.graalvm.polyglot.PolyglotException: ReferenceError: "UserMockHelper" is not defined
</code>
org.graalvm.polyglot.PolyglotException: ReferenceError: "UserMockHelper" is not defined
The Javascript function can still be executed directly in the scenario, but it does not work within a JSON validation, such as
<code>And match response.docs[0] contains { timestamp: "#? isValidDateTime(_)" }
</code>
<code>And match response.docs[0] contains { timestamp: "#? isValidDateTime(_)" }
</code>
And match response.docs[0] contains { timestamp: "#? isValidDateTime(_)" }
I now always get the following error message:
<code>TypeError: execute on {} failed due to: Message not supported.
</code>
<code>TypeError: execute on {} failed due to: Message not supported.
</code>
TypeError: execute on {} failed due to: Message not supported.