Skip to content
Permalink
Browse files

feat(testing): add option test.browsers to run tests in additional br…

…owsers
  • Loading branch information
jyounce committed Jul 16, 2015
1 parent f9dcc90 commit 5d6864de517542979682dd11547608c1e62cbda0
Showing with 56 additions and 1 deletion.
  1. +1 −0 README.md
  2. +1 −0 config.coffee
  3. +6 −0 config/config-options.coffee
  4. +47 −0 config/config-test.coffee
  5. +1 −1 tasks/test/test-config.coffee
@@ -137,6 +137,7 @@ gulp rapid-build:prod
# exclude.from.cacheBust = (array of strings) = file paths: exclude files from the cache bust
# exclude.from.minFile[scripts|styles] = (array of strings) = file paths: exclude script or style files from automatically being generated in the scripts.min.js or styles.min.css file
# exclude.from.spaFile[scripts|styles] = (array of strings) = file paths: exclude script or style files from automatically being generated in the spa.html file
# test.browsers = (array of browser names) = phantomjs will run by default, optional browser names are ['chrome', 'firefox', 'ie', 'safari']
# =============================================================================================================================================================================================================================
```

@@ -25,6 +25,7 @@ module.exports = (rbDir, options) ->
config = require("#{config.req.config}/config-order") config, options
config = require("#{config.req.config}/config-globs") config
config = require("#{config.req.config}/config-bower") config, options
config = require("#{config.req.config}/config-test") config, options

# format
# ======
@@ -41,6 +41,7 @@
# exclude.from.cacheBust = (array of strings) = file paths: exclude files from the cache bust
# exclude.from.minFile[scripts|styles] = (array of strings) = file paths: exclude script or style files from automatically being generated in the scripts.min.js or styles.min.css file
# exclude.from.spaFile[scripts|styles] = (array of strings) = file paths: exclude script or style files from automatically being generated in the spa.html file
# test.browsers = (array of browser names) = phantomjs will run by default, optional browser names are ['chrome', 'firefox', 'ie', 'safari']
# =============================================================================================================================================================================================
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
@@ -131,6 +132,10 @@ module.exports = (config, options) ->
options.exclude.from.spaFile.scripts = null if not isType.array options.exclude.from.spaFile.scripts
options.exclude.from.spaFile.styles = null if not isType.array options.exclude.from.spaFile.styles

testOptions = ->
options.test = {} if not isType.object options.test
options.test.browsers = null if not isType.array options.test.browsers

# init
# ====
distAndSrcOptions() # must be first
@@ -141,6 +146,7 @@ module.exports = (config, options) ->
spaOptions()
minifyOptions()
excludeOptions()
testOptions()

# logs
# ====
@@ -0,0 +1,47 @@
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
_test = require("#{config.req.helpers}/test")()

# init test
# =========
test = {}

# browsers
# ========
getBrowsers = ->
browsers = ['PhantomJS'] # default
browserOpts = ['Chrome', 'Firefox', 'IE', 'Safari'] # case sensitive
userBrowsers = options.test.browsers
return browsers unless userBrowsers
return browsers unless userBrowsers.length
# format the browser names, they are case sensitive
userBrowsers = userBrowsers.map (string) ->
string.trim().toLowerCase()
for userBrowser in userBrowsers
match = null
for browser in browserOpts
if browser.toLowerCase() is userBrowser
match = browser; break
continue unless match
browsers.push match
browsers

test.browsers = getBrowsers()

# add test to config
# ==================
config.test = test

# logs
# ====
# log.json test, 'test ='

# tests
# =====
_test.log 'true', config.test, 'add test to config'

# return
# ======
config


@@ -22,5 +22,5 @@ module.exports = (config) ->
basePath: rbConfig.app.dir
files: getScripts 'files.json'
frameworks: ['jasmine']
browsers: ['PhantomJS'] # 'Chrome', 'Firefox', 'IE', 'Safari'
browsers: rbConfig.test.browsers # see config-test.coffee
singleRun: true

0 comments on commit 5d6864d

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