1

We have a distributed project where we're providing a few additional utility functions via a javascript file. When we use karate.fail() in js file or function, it's failing as the evaluation happens at js level when the js file is called from karate.call(). However, we do not see any background steps that were intended to be displayed in the report when karate.fail() is called from a javascript file.

How could we display background steps when karate.fail() is called from a javascript file?

Harish Ghorpade
  • 71
  • 1
  • 1
  • 6

1 Answers1

0

Please try the 1.0 RC version: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

If it does not work, you need to contribute code or look for another framework.

Also see: https://stackoverflow.com/a/47366897/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks @Peter Thomas for your reply. Let me give more details. As mentioned we're distributing a framework with additional utility methods like authentication(), DBConnection() etc. In one of the utility methods, we have a requirement to verify few user details from the down-line project. To achieve this we're using IIFEs - Immediately Invoked Function Expressions in js from karate-base.js. If this verification fails, we're invoking karate.fail(), which in-turn is causing frame-work loading to be failed. – Harish Ghorpade Mar 08 '21 at 14:25
  • karate.fail() works fine when we use it down-the line project. Please let us know if there is a feasible solution like soft-fail in karate by throwing an exception if something fails to load at karate-base.js. – Harish Ghorpade Mar 08 '21 at 14:28
  • @HarishGhorpade you can do normal `try {} catch (e) {}` in js,here is an example: https://stackoverflow.com/a/63835945/143475 - if that does not solve your problem, I have nothing to add to my previous comment – Peter Thomas Mar 08 '21 at 15:44
  • Thanks @PeterThomas. Just a follow-up. Is there any way we could override 'com.intuit.karate.exception.KarateException: evaluation of classpath:karate-base.js' exception message with a user-defined message. – Harish Ghorpade Mar 09 '21 at 07:39
  • @HarishGhorpade assume the answer is no please. if you ask my honest opinion, this should be the least of your worries. are you trying to do testing or worrying about pretty reports ? – Peter Thomas Mar 09 '21 at 07:51