Skip to content
Permalink
Browse files

feat(testing): add port option for the karma server

  • Loading branch information
jyounce committed Jul 16, 2015
1 parent b21d6fd commit 692e62f8e754939d120d1df4661434fb7115bfdf
@@ -110,8 +110,9 @@ gulp rapid-build:prod
# src.client.bower.dir = (string) defaults to 'bower_components'
# src.client.libs.dir = (string) defaults to 'libs' = 3rd party libraries that aren't bower components
# src.server.dir = (string) defaults to 'server'
# ports.server = (int) defaults to 3000
# ports.reload = (int) defaults to 3001
# ports.server = (int) defaults to 3000, web server port
# ports.reload = (int) defaults to 3001, browsersync server port
# ports.test = (int) defaults to 9876, karma server port
# order[scripts|styles][first|last] = (array of strings) = file paths
# angular.modules = (array of strings) = additional angular modules to load, already loaded are ['ngResource', 'ngRoute', 'ngSanitize'] and 'ngMockE2E' based on angular.httpBackend options
# angular.moduleName = (string) defaults to 'app' = application module name, value for ng-app
@@ -13,6 +13,7 @@ module.exports = (rbDir, options) ->
config = require("#{config.req.config}/config-env") config
config = require("#{config.req.config}/config-rb") config, rbDir
config = require("#{config.req.config}/config-app") config, options
config = require("#{config.req.config}/config-ports") config, options
config = require("#{config.req.config}/config-file-names") config
config = require("#{config.req.config}/config-minify") config, options
config = require("#{config.req.config}/config-dist-and-src") config, options
@@ -7,12 +7,6 @@ module.exports = (config, options) ->
app = {}
app.dir = config.req.app

# ports
# =====
app.ports = {}
app.ports.server = options.ports.server or 3000
app.ports.reload = options.ports.reload or 3001

# add app to config
# =================
config.app = app
@@ -1,48 +1,5 @@
# API - Prep Options
# dist.dir = (string) defaults to 'dist'
# dist.client.dir = (string) defaults to 'client'
# dist.client[images|scripts|styles|test|views].dir = (string) defaults to property name
# dist.client.bower.dir = (string) defaults to 'bower_components'
# dist.client.libs.dir = (string) defaults to 'libs' = 3rd party libraries that aren't bower components
# dist.server.dir = (string) defaults to 'server'
# dist.server.file = (string) defaults to 'routes.js'
# src.dir = (string) defaults to 'src'
# src.client.dir = (string) defaults to 'client'
# src.client[images|scripts|styles|test|views].dir = (string) defaults to property name
# src.client.bower.dir = (string) defaults to 'bower_components'
# src.client.libs.dir = (string) defaults to 'libs' = 3rd party libraries that aren't bower components
# src.server.dir = (string) defaults to 'server'
# ports.server = (int) defaults to 3000
# ports.reload = (int) defaults to 3001
# order[scripts|styles][first|last] = (array) expects file paths
# angular.modules = (array) additional angular modules
# angular.version = (string) defaults to '1.x'
# angular.moduleName = (string) application module name
# angular.httpBackend.dev = (boolean) defaults to false
# angular.httpBackend.prod = (boolean) defaults to false
# angular.httpBackend.dir = (string) defaults to 'mocks'
# angular.templateCache.dev = (boolean) defaults to false
# angular.templateCache.useAbsolutePaths = (boolean) defaults to false
# spa.title = (string) defaults to package.json name
# spa.description = (string) defaults to package.json description
# spa.src.file = (string) defaults to 'spa.html'
# spa.src.dir = (string) defaults to null
# spa.dist.file = (string) defaults to spa.src.file or 'spa.html'
# spa.placeholders = (array of strings) = optionals: ['scripts', 'styles', 'description', 'moduleName', 'title'] or ['all']
# minify.css.styles = (boolean) defaults to true
# minify.css.splitMinFile = (boolean) defaults to true
# minify.html.views = (boolean) defaults to true
# minify.html.templateCache = (boolean) defaults to true
# minify.js.scripts = (boolean) defaults to true
# minify.js.mangle = (boolean) defaults to true
# minify.spa.file = (boolean) defaults to true
# minify.cacheBust = (boolean) defaults to true
# exclude.angular.files = (boolean) defaults to false
# 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']
# =============================================================================================================================================================================================
# API Options Prep
# ================
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
isType = require "#{config.req.helpers}/isType"
@@ -70,6 +27,7 @@ module.exports = (config, options) ->
options.ports = {} if not isType.object options.ports
options.ports.server = null if not isType.number options.ports.server
options.ports.reload = null if not isType.number options.ports.reload
options.ports.test = null if not isType.number options.ports.test

orderOptions = ->
options.order = {} if not isType.object options.order
@@ -0,0 +1,28 @@
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
test = require("#{config.req.helpers}/test")()

# init ports
# ==========
ports = {}
ports.server = options.ports.server or 3000
ports.reload = options.ports.reload or 3001
ports.test = options.ports.test or 9876

# add ports to config
# ===================
config.ports = ports

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

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

# return
# ======
config


@@ -2,7 +2,7 @@ path = require 'path'
express = require 'express'
config = require './config.json'
app = express()
port = config.app.ports.server
port = config.ports.server
spa = config.spa.dist.file
client = config.dist.app.client.dir
appPath = config.dist.app.server.scripts.path
@@ -11,7 +11,7 @@ appFilePath = path.join appPath, appFile # app server dist entry script

app.use express.static client
app.listen port, ->
console.log "Server Started on #{config.app.ports.server}"
console.log "Server Started on #{config.ports.server}"

app.get '/', (req, res) ->
res.sendFile spa, root:client
@@ -5,8 +5,8 @@ module.exports = (gulp, config) ->

bsConfig =
files: config.glob.browserSync
proxy: "http://localhost:#{config.app.ports.server}/"
port: config.app.ports.reload
proxy: "http://localhost:#{config.ports.server}/"
port: config.ports.reload
browser: 'google chrome'
# open: false

@@ -9,4 +9,4 @@ module.exports = (gulp, config) ->
defer.promise

gulp.task "#{config.rb.prefix.task}open-browser", ->
runTask config.app.ports.server
runTask config.ports.server
@@ -20,5 +20,6 @@ module.exports = (config) ->
browsers: rbConfig.test.browsers # see config-test.coffee
files: getScripts 'test-files.json'
frameworks: ['jasmine']
port: rbConfig.ports.test
reporters: ['dots']
singleRun: true

0 comments on commit 692e62f

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