Comments (13)
FWIW I was following the instructions here to set up VTL unit testing:
https://mechanicalrock.github.io/2020/04/27/ensuring-resolvers-aren't-rejected.html
I have not yet tried another option I stumbled on:
https://github.com/skyhookadventure/appsync-template-tester
from velocity.js.
Can you provide the basic logic code of the function createVtlContext
. I need that function to run you test code.
from velocity.js.
Can you provide the basic logic code of the function
createVtlContext
. I need that function to run you test code.
sorry, forgot about that:
function createVtlContext(args) {
const util = utils.create([], new Date(Date.now()), Object())
const context = {
args,
arguments: args
}
return {
util,
utils: util,
ctx: context,
context
}
}
from velocity.js.
utils.create
is missing.
from velocity.js.
Not sure what you mean exactly @shepherdwind:
function createVtlContext(args) {
const util = utils.create([], new Date(Date.now()), Object()) ## calling utils.create here
[...]
In tests with other templates (ie, try the below), parsing and rendering works fine:
const ast = parse(`
#set( $keyFields = ["id"] )
`);
from velocity.js.
I need the code of utils.create
, I need it to run the code you provide.I need complete, repeatable code to reproduce the problem.
from velocity.js.
I need the code of
utils.create
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 🙏
from velocity.js.
@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
from velocity.js.
@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
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.
from velocity.js.
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.
from velocity.js.
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
from velocity.js.
I know what the problem is, I optimized the exception stack display, and now the exceptions look like this.
TypeError: map.keySet is not a function on $util.map.copyAndRemoveAllKeys($ctx.args.input,$keyFields).entrySet() at L/N 3:6
at Object.copyAndRemoveAllKeys (node_modules/[email protected]@amplify-appsync-simulator/lib/velocity/util/map-utils.js:34:14)
at Velocity.getPropMethod (src/compile/references.js:315:23)
at Velocity.getAttributes (src/compile/references.js:188:20)
And the code of amplify-appsync-simulator/lib/velocity/util/map-utils.js:34:14
like this
copyAndRemoveAllKeys: function (map, keys) {
var keysStr = keys.toJSON();
var result = map
.keySet()
.toJSON()
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 #set
condiction.
from velocity.js.
new version 2.0.5 published
from velocity.js.
Related Issues (20)
- Dashes in Identifiers HOT 1
- Support format quiet syntax $!{reference}
- String.replace() is not global HOT 2
- Map.remove() is not implemented HOT 2
- String pipe symbol not implemented HOT 1
- Support the $util.qr directive HOT 1
- IE or older browsers not supported!!! HOT 1
- Bug with #set inside #foreach: setting properties on loop variable from foreach doesn't work HOT 1
- TypeError: Cannot read property 'charCodeAt' of undefined HOT 1
- 如何实现webpack的热更新? HOT 2
- String matches does not work HOT 2
- 变量名称是null时报错 HOT 1
- How to figure out which references in AST are able to be set in context HOT 2
- Support method with arguments HOT 2
- Parse String to Int HOT 2
- ESM module build? HOT 10
- #set with array fails for unknown reason HOT 1
- 无法解析vue中使用element-ui的$message语法 HOT 1
- Date functions not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from velocity.js.