How can I do continuous assembly / unit testing in Coffeescript?

I am writing (more and more) a unit test suite using Coffeescript and node.js. I create files using the "watch" option for coffee (-w)

coffee -w -b -c -o web/ src/

My problem is that running unit tests takes 20 seconds (I assume to compile in .js).

If possible, I would like to automatically run unit tests when changing a file (compiled .js), which will save you a long wait for results.

My current Cakefile:

fs            = require 'fs'
{print}       = require 'sys'
{spawn, exec} = require 'child_process'

build = (watch, callback) ->
  if typeof watch is 'function'
    callback = watch
    watch = false
  options = ['-c', '-b', '-o', 'web', 'src']
  options.unshift '-w' if watch

  coffee = spawn 'coffee', options
  coffee.stdout.on 'data', (data) -> print data.toString()
  coffee.stderr.on 'data', (data) -> print data.toString()
  coffee.on 'exit', (status) -> callback?() if status is 0

task 'test', 'Run the test suite', ->
  build ->
    require.paths.unshift __dirname + "/lib"
    {reporters} = require 'nodeunit'
    process.chdir __dirname
    reporters.default.run ['test']
+5
source share
1 answer

Take a look at Cakefile for my connect-assets project: https://github.com/adunkman/connect-assets/blob/master/Cakefile

, sstephenson ( , ), , .

+1

All Articles