-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Response object not natively available when calling features from karate-config.js #1835
Comments
that's weird - since I'm having a very busy month cc @joelpramos since he is familiar with this code |
I’m touching the calling of features with the fix I’m doing for #1793 so I’ll look into this one too. |
… work of sharing config across shared contexts
@joelpramos i still see the issue when trying latest develop branch |
Took a look into your scenario bit better - problem is when calling a Feature with an array (i.e. multiple executions) in sharedScope the variables are not getting propagated to the parent. I noticed that when fixing the original issue that lead me to refactor some details on the callFeature ( The fix is to replace
i.e. the else condition will try to propagate all variables of the called Feature. Looking for yours and @ptrthomas opinion though... how do we think this should behave? Since it's an iteration we'll have the same variables with multiple values (e.g. the response object itself in case of calling an API) so is there value in propagating the shared scope? I guess that was the design pre v1.0 so I'm ok implementing that behavior (and do the same to propagate any |
Btw to reproduce just need to add an array as argument in the Response will become an array thus it won't propagate the response to the caller. |
@joelpramos I'm ok to propagate, a |
@kirksl fixed in develop |
thank you @joelpramos |
1.2.0 released |
tagging this to #2009 - I'm going to undo this change. so a "call loop in shared scope" will never propagate variables back to caller. it doesn't make sense |
note that this commit reverts the change made in #1835
This issue started occurring with Karate 1.0
The following feature file will fail when called from karate-config with error
org.graalvm.polyglot.PolyglotException: ReferenceError: "response" is not defined
This same feature file will succeed when called outside of/after karate-config
The same feature file, now edited, setting call to a variable and referencing the variable works
Attaching a demo project referencing the issue
myproject.zip
To Repro
Open /src/test/java/com/repro/tests/test.feature and run @test=test1 scenario
Witness error in console or /build/karate.log
Open /src/test/java/com/repro/setup/customers/customers_setup.feature and goto line 11 to reach problematic code.
Comment out
option 1
section of codeUncomment
option 2
section of codeRun @test=test1 scenario again
The text was updated successfully, but these errors were encountered: