-
Notifications
You must be signed in to change notification settings - Fork 143
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
Bug with rendering #foreach and $util.map.copyAndRemoveAllKeys #140
Comments
FWIW I was following the instructions here to set up VTL unit testing: I have not yet tried another option I stumbled on: |
Can you provide the basic logic code of the function |
sorry, forgot about that:
|
|
Not sure what you mean exactly @shepherdwind:
In tests with other templates (ie, try the below), parsing and rendering works fine:
|
I need the code of |
Sorry; my misunderstanding. I am using utils from the AWS amplify-appsync-simulator As I mentioned, I am just following the code template from https://mechanicalrock.github.io/2020/04/27/ensuring-resolvers-aren't-rejected.html Thanks for your patience 🙏 |
@shepherdwind Random Q: what is this line doing? velocity.js/src/compile/references.js Line 271 in 585bdab
as far as I can tell, this will never be true, and so the first branch will never execute Also, the current test suite never executes it as well Not sure if related to this issue, but just discovered it while investigating |
… pos is missing in error situations
Addressing #140, also added a bit more defensive code in case pos is missing in error situations
The code was submitted by others #124 , I did not look closely at the specific implementation at the time, and just tried it does not run to this branch. Also,Did the #141 pr fix the bug you mentioned here with that commit? I'll publish a new version directly, and then I will find time to refactor this repository code later, it's a bit too old. |
I am sorry I don't know about AWS amplify-appsync-simulator very much, I have never touched this tool before . A pr with test code would be more useful, and it would be perfect if it included test pass code. |
So the #141 pr fixed a related issue which is that the error output was itself erroring and gave unusable output. I'm still not yet sure what is the root cause of the original issue Possibly related to this? serverless-appsync/serverless-appsync-simulator#106 |
I know what the problem is, I optimized the exception stack display, and now the exceptions look like this.
And the code of
So the root cause of this issue is the map do not have the keySet methods. I publish a new beta version, so you can try the beta version on your local machine. There are two ways to solve this problem, first wrap the input to an map, for example velocity.js/test/issues.test.js Lines 34 to 39 in fa0b7a3
The second one, maybe the complier option valueMapper should map every value, now the valueMapper only handle |
new version 2.0.5 published |
I am trying to use
jest
to test my local VTL templatesusing:
OSX 11.6
node v12.18.0
amplify-velocity-template: 1.4.5
jest: 26.6.3
I just create, parse, and render a simple template with:
when I render at the last line, I get the error:
I can't figure out why or if there is something wrong with my code - I believe my code is straight from AWS Amplify codegen and does work when run as an AppSync API call on the AWS stack.
Thanks for any pointers !
The text was updated successfully, but these errors were encountered: