05-15-2021 09:00 AM
I would like to be able to write tests for my expression libraries using and editor and javascript.
I have tried require() and import, but have not been successful
05-17-2021 08:31 AM
Hi @Tim,
The Snaplogic Expression Language is an in-house-built custom language that is behaviorally mostly like Javascript however, it is not Javascript and can not be used as so in a Javascript editor.
Maybe a unit test/validation pipeline is your best way to achieve this.
05-17-2021 10:16 AM
Thank you for the response.
I did learn through more research that the engine is the Nashorn engine and due to the fact that it is deprecated in Java 11 there will not be support for it in VScode. Some people have made some progress.
I do have a test pipeline right now. I am finding more discrepancies between Javascript the language spec and Nashorn the implementation. (which is why it is deprecated). That has to be a hard place for you to be in, a new engine could be a backwards compatibility nightmare.
05-17-2021 11:00 AM
Actually, our Expression Language is not built on top of Nashorn at all. You may have been reading a post about the script snap using a Javascript setting, which is not involved with the expression language.
The Expression Language is a completely custom-built language that actually gets compiled into Java Byte code to be executed on the JCC.
05-17-2021 12:35 PM
That is good information. I would prefer to write expressions and expression libs than script snaps.
I do wish there was a way to test them from Javascript or Java in a local editor. Something to consider. Probably a lot of work when many of your users may not use a lot of local coding practices?