diff --git a/lib/middleware/runner.js b/lib/middleware/runner.js index 7c0d13dbc..7d8c2090f 100644 --- a/lib/middleware/runner.js +++ b/lib/middleware/runner.js @@ -4,6 +4,7 @@ * It basically triggers a test run and streams stdout back. */ +var _ = require('lodash') var path = require('path') var helper = require('../helper') var log = require('../logger').create() @@ -48,7 +49,7 @@ var createRunnerMiddleware = function (emitter, fileList, capturedBrowsers, repo }) log.debug('Setting client.args to ', data.args) - config.client.args = data.args + config.client.args = _.merge(config.client.args, data.args) var fullRefresh = true diff --git a/test/unit/middleware/runner.spec.js b/test/unit/middleware/runner.spec.js index 8e7228aba..42dde2865 100644 --- a/test/unit/middleware/runner.spec.js +++ b/test/unit/middleware/runner.spec.js @@ -51,7 +51,7 @@ describe('middleware.runner', () => { nextSpy = sinon.spy() response = new HttpResponseMock() - config = {client: {}, basePath: '/'} + config = {client: {args: ['clientArg']}, basePath: '/'} handler = createRunnerMiddleware( emitter, @@ -166,6 +166,28 @@ describe('middleware.runner', () => { request.emit('end') }) + it('calling run with no client args should not overwrite existing client.args', (done) => { + capturedBrowsers.add(new Browser()) + sinon.stub(capturedBrowsers, 'areAllReady', () => true) + + emitter.once('run_start', () => { + expect(config.client.args).to.deep.equal(['clientArg']) + done() + }) + + var RAW_MESSAGE = '{"args": []}' + + var request = new HttpRequestMock('/__run__', { + 'content-type': 'application/json', + 'content-length': RAW_MESSAGE.length + }) + + handler(request, response, nextSpy) + + request.emit('data', RAW_MESSAGE) + request.emit('end') + }) + it('should refresh explicit files if specified', (done) => { capturedBrowsers.add(new Browser()) sinon.stub(capturedBrowsers, 'areAllReady', () => true)