How to let mocha work with tamejs?
-
08-06-2021 - |
Question
I want to use tamejs to write mocha tests, but mocha doesn't support it by default.
Is there any way to let mocha work with tamejs? I don't want to write .tjs
files and compiling them into .js
each time before running tests.
Solution
You can specify an external compiler in mocha with --compilers
option
--compilers
coffee-script is no longer supported out of the box. CS and similar transpilers may be used by mapping the file extensions (for use with –watch) and the module name. For example --compilers coffee:coffee-script.
So, create mocha.opts
in your app/tests path and add :
--compilers tjs:tamejs
Then every extension .tjs
will be compiled automatically when starting mocha
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow