1

I have a nodejs script which is being used to encrypt a plain text password using npm-forge / forge() function. Next I intend to call this nodejs file during my Karate feature execution to generate the encrypted password in run-time and further make a login POST API call with it.

The Login POST API call works just fine on it's own, but the call() fails with the exception : org.graalvm.polyglot.PolyglotException: ReferenceError: "require" is not defined

* def myFun = read('encryptPass.js')
* def responseData = call myFun
* print responseData

Reponse : org.graalvm.polyglot.PolyglotException: ReferenceError: "require" is not defined

1 Answers1

0

Yes the JS engine in Karate is a simplified one, while it can support Node in theory, it is designed for only plain vanilla EC6.

I think you will have better results by calling logic via the CLI. Refer this answer: https://stackoverflow.com/a/73321719/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248