Skip to content

Instantly share code, notes, and snippets.

@albertosouza
Created January 11, 2014 21:19
Show Gist options
  • Save albertosouza/8377013 to your computer and use it in GitHub Desktop.
Save albertosouza/8377013 to your computer and use it in GitHub Desktop.
Cakefile for run sails.js testes with mocha config and suport to --grep <string> option
# Cakefile
{exec} = require "child_process"
option '', '--grep [string]', 'only run tests matching <pattern>'
REPORTER = "spec"
task "test", "run all tests", (options)->
grep
grep = ('--grep ' + options.grep) if options.grep
exec "NODE_ENV=test
./node_modules/.bin/mocha
--reporter #{REPORTER}
--require tests/testHelper.js
--colors
"+grep+"
--ui bdd
tests/index.js
", (err, output) ->
console.error err if err
console.log output
task "test_bail", "bail after first test failure", (options)->
grep
grep = ('--grep ' + options.grep) if options.grep
exec "NODE_ENV=test
./node_modules/.bin/mocha
--reporter #{REPORTER}
--require tests/testHelper.js tests/index.js
--colors
--growl
"+grep+"
--ui bdd
", (err, output) ->
console.error err if err
console.log output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment