Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript generator function "not defined" after upgrade to 1.3.0.RC2 #2120

Closed
mattkoss opened this issue Sep 8, 2022 · 2 comments
Closed

Comments

@mattkoss
Copy link

mattkoss commented Sep 8, 2022

After upgrading from 1.2.1.RC2 to 1.3.0.RC2, my javascript generator function used by Scenario Outline is somehow not visible to karate anymore.
All works fine again after downgrade.

Here is an example code:

  Background:
    * callonce read('classpath:features_common/ReadQuoteData.feature')

    # generator function that repeats all the quotes as per the supplied number of execution cycles
    * def quoteProducer =
    """
    function(i) {
        if (i == quoteData.length * executionCycles) {
          return null;
        } else {
          return quoteData[i % quoteData.length];
        }
    }
    """

  Scenario Outline:
    * def testQuote = __row
    * print "processing quote " + __num + " (" + testQuote.id + ")"

    # call configured channel-specific test suite
    * def getQuoteResult = call read("../featuresXXX")

    Examples:
      | quoteProducer |

Error message produced in 1.3.0.RC2:


======================================================
>>> failed features:
js failed:
>>>>
01: quoteProducer
<<<<
org.graalvm.polyglot.PolyglotException: ReferenceError: "quoteProducer" is not defined
- <js>.:program(Unnamed:1)

classpath:features_apt/AptTestSuite.feature:38
<<<

@mattkoss mattkoss changed the title Javascript generator function "not found" after upgrade to 1.3.0.RC2 Javascript generator function "not defined" after upgrade to 1.3.0.RC2 Sep 8, 2022
@ptrthomas
Copy link
Member

@mattkoss yep ! please read this and I think that should answer everything. yes I still need to document this :(

#1905

@mattkoss
Copy link
Author

mattkoss commented Sep 9, 2022

I can indeed confirm that the following now works with 1.3.0.RC2:

 @setup
  Scenario:
    * callonce read('classpath:features_common/ReadQuoteData.feature')

    # generator function that repeats all the quotes as per the supplied number of execution cycles
    * def quoteProducer =
    """
    function(i) {
        if (i == quoteData.length * executionCycles) {
          return null;
        } else {
          return quoteData[i % quoteData.length];
        }
    }
    """

  Scenario Outline:
    * def testQuote = __row
    * print "processing quote " + __num + " (" + testQuote.id + ")"

    # call configured channel-specific test suite
    * def getQuoteResult = call read("../featuresXXX")

    Examples:
      | karate.setup().quoteProducer |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants