Home > Mobile >  In Karate, how to disable the output of every line of the .js file when is failing?
In Karate, how to disable the output of every line of the .js file when is failing?

Time:08-18

We run some initial scenarios directly from karate-config.js via karate.callSingle.

Problem is, when any of those scenarios fail, the whole karate-config.js file is printed in logs, line by line.

We found where this behaviour is written: https://github.com/karatelabs/karate/blob/3ea821f9d326b7eb96eaf0e7ab8efffc52c7f831/karate-core/src/main/java/com/intuit/karate/graal/JsEngine.java#L210

which is a static function.

Is it possible to modify this behavior to just print the name of the .js file, for instance?

CodePudding user response:

That routine has evolved over 5 years to make it easier for people to figure out what went wrong in JS. You are welcome to contribute code to make it better or maybe we can use a separate logger namespace.

Personal opinion follows:

And when things fail, I think it is a good thing to provide enough information for troubleshooting. Failures should be a rare occurrence and should not be happening all the time. Finally, let me say that you should not be having very large JS files when you use Karate, and if you are doing that, I consider it an anti-pattern.

  • Related