I'm trying to set up an application using coffeescript, jade and mocha. However, when I run mocha, even with the --compilers flag, jade templates don't load.
I have done a similar setup using brunch, and jade templates get automatically converted into commonjs modules there. Under node, they do not appear to be loaded as modules. Is there a proper way to do this?
Right now, I am running mocha like so: mocha --compilers coffee:coffee-script,jade:jade
I'm sure there's a way to jury-rig something along those lines, but the thing to understand is that .coffee files compile to .js files, and when written as CommonJS modules, node can run them. However, .jade templates just compile to a single javascript function as opposed to a full CommonJS module, so node itself is never going to be able to make use of .jade templates without some other module to actually integrate those standalone compiled template functions into the commonjs module system. I would guess automated build tools like brunch are adding a little wrapper code boilerplate to make the templates into commonjs modules.
Grunt is a pretty good way to go.
There are plugins for coffeescript, jade, and mocha.
Using watch, you can automatically compile on file change.
EDIT: This would be to precompile, and not render jade/coffee on the fly.
EDIT2: For general coffeescript/mocha testing advice, I've found this article very helpful.