Home > Back-end >  Karate- Getting current date and manipulating it is not returning anything [duplicate]
Karate- Getting current date and manipulating it is not returning anything [duplicate]

Time:10-07

I apologize in advance if this seems like it's in the wrong place. However, what I have seems to work in pure JavaScript. However, when added in my Karate script, it's returning an empty object.

I have the following script:

* def currentDateMinusOne = new Date(new Date().setFullYear(new Date().getFullYear() - 1))
* karate.log("current date minus one year:", currentDateMinusOne)

The Karate log spits out an empty {}. Any ideas on what could be going on?

CodePudding user response:

I don't know if the JavaScript Date behaves properly using the Karate JS engine, and I personally have never used it. You are welcome to experiment and report your findings.

My recommendation is to use Java interop. This example should get you going: https://stackoverflow.com/a/60945563/143475

  • Related