     .pipe gulp.dest './dist/css/'
 
 
-gulp.task 'clean', (cb) ->
-
-  rimraf './dist', cb
-
-
-gulp.task 'production', [ 'clean' ], ->
-
-  production = yes
-
-  gulp.start 'build', ->
-    gutil.log 'Building for production is completed,
-               you can now deploy ./dist folder'
-
+gulp.task 'clean', (cb) -> rimraf './dist', cb
+
+gulp.task 'enable-test-watch', [ 'default' ], ->
+
+  gulp.watch paths.test.app,   [ 'single-test' ]
+  gulp.watch paths.test.cases, [ 'single-test' ]
+
+  gulp.start 'single-test'
+
+gulp.task 'enable-prod', -> production = yes
+
+gulp.task 'disable-open', -> openApp = no
+
+gulp.task 'prod-build', [ 'enable-prod', 'serve-only', 'test' ]
+
+gulp.task 'production', [ 'prod-build' ], ->
+
+  gutil.log 'Building for production is completed,
+             you can now deploy ./dist folder'
+
+gulp.task 'test', [ 'disable-open', 'serve-only' ], (done) ->
+
+  gulp
+    .src ['./test/*.coffee'], read: no
+    .pipe mocha
+      reporter: 'list'
+      require: 'coffeescript/register'
+
+    .on 'end', ->
+      browserSync.exit()
+
+    .once 'error', ->
+      @emit 'end'
+
+gulp.task 'single-test', ->
+
+  gulp
+    .src ['./test/*.coffee'], read: no
+    .pipe mocha
+      reporter: 'list'
+      require: 'coffeescript/register'
+
+    .once 'error', ->
+      @emit 'end'
+
+
+gulp.task 'test-watch', [ 'enable-test-watch' ]
+
+gulp.task 'compile', [ 'compile-vendors', 'compile-scripts' ]
 
 gulp.task 'build',   [
-  'compile-scripts', 'styles', 'entry-point', 'export-kd', 'images'
+  'compile', 'styles', 'entry-point', 'export-kd', 'images'
+]
+
+gulp.task 'serve-only', [
+  'build', 'server'
 ]
 
 gulp.task 'default', [

# kind of SPA mode.
# see:
# https://github.com/BrowserSync/browser-sync/issues/204#issuecomment-60410751
historyFallback = require('connect-history-api-fallback')

globalBundler   = null

paths           =

  images        :
    source      : './app/images/*'
    destination : './dist/images/'
  test          :
    app         : './dist/**/*'
    cases       : './test/*.coffee'


handleError = (err) ->
