Skip to content
Permalink
Browse files

fix(testing): do not run tests if there are no test scripts

  • Loading branch information
jyounce committed Jul 16, 2015
1 parent 805e598 commit 227ec95600c8ec39b9bc2e548aa4a418d2217794
Showing with 41 additions and 33 deletions.
  1. +6 −1 tasks/build/build-test-files.coffee
  2. +35 −7 tasks/test/run-tests.coffee
  3. +0 −25 tasks/test/test-config.coffee
@@ -11,7 +11,11 @@ module.exports = (gulp, config) ->
# Global Objects
# ==============
DevFiles = {}
TestFiles = client: scripts: [], styles: []
TestFiles = client:
scriptsTestCount: 0
stylesTestCount: 0
scripts: []
styles: []

# Build Task
# ==========
@@ -42,6 +46,7 @@ module.exports = (gulp, config) ->
gulp.src src, buffer: false
.on 'data', (file) ->
_path = pathHelp.format(file.path).replace "#{appDir}/", ''
TestFiles.client["#{type}TestCount"]++
TestFiles.client[type].push _path
.on 'end', ->
defer.resolve()
@@ -1,20 +1,48 @@
module.exports = (gulp, config) ->
q = require 'q'
Server = require('karma').Server
q = require 'q'
path = require 'path'
Server = require('karma').Server
moduleHelp = require "#{config.req.helpers}/module"
promiseHelp = require "#{config.req.helpers}/promise"

# karma options
# =============
opts =
configFile: "#{config.req.tasks}/test/test-config.coffee"
karmaConfig =
autoWatch: false
basePath: config.app.dir
browsers: config.test.browsers # see config-test.coffee
frameworks: ['jasmine', 'jasmine-matchers']
port: config.ports.test
reporters: ['dots']
singleRun: true

# helpers
# =======
getTests = (jsonEnvFile) ->
jsonEnvFile = path.join config.templates.files.dest.dir, jsonEnvFile
moduleHelp.cache.delete jsonEnvFile
tests = require(jsonEnvFile).client
tests

# register task
# =============
gulp.task "#{config.rb.prefix.task}run-tests", ->
defer = q.defer()
server = new Server opts, (exitCode) ->
console.log "Karma has exited with #{exitCode}."
defer = q.defer()
tests = getTests 'test-files.json'

# No Test Scripts
if not tests.scriptsTestCount
console.log 'no test scripts to run'.yellow
return promiseHelp.get defer
else
karmaConfig.files = tests.scripts

# Rus Tests
server = new Server(karmaConfig, (exitCode) ->
console.log "karma has exited with #{exitCode}".yellow
defer.resolve()
process.exit exitCode
)
server.start()
defer.promise

This file was deleted.

0 comments on commit 227ec95

Please sign in to comment.
You can’t perform that action at this time.