문제

I am trying to test an adobe ExtendScript file with Mocha. Mocha is all setup and works fine but stops when it encounters non-valid javascript characters.

The problem is, Extendscript uses a custom syntax to import files: #include "path/to/file.jsx" and to target a specific application: #target "aftereffects".

When I try running mocha I receive a SyntaxError: Unexpected string error on these lines.

Is there a flag or a way to tell mocha I want it to skip those lines?

도움이 되었습니까?

해결책

There is no flag to tall Mocha to ignore such lines. Some options that come to mind:

  1. Use a build system like Grunt to generate pure JS files from your ExtendScript files, and then have Mocha run on result of the transformation.

  2. Hook into the --compilers option. You would have to register an ExtendScript compiler with Node.js or create your own fake compiler that just strips out the #include directives and register this compiler with Node.js. A good example of how to register such compiler is provided by CoffeeScript.

I think the first method would be safest because looking at Node.js' documentation, I see that the way CoffeeScript register's itself is marked "deprecated".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top