Skip to content

Commit

Permalink
feat(config): Pass CLI arguments to karma.config.js.
Browse files Browse the repository at this point in the history
Closes #1561
  • Loading branch information
danielsiwiec committed Sep 9, 2015
1 parent 9690d4e commit 70cf903
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/config.js
Expand Up @@ -300,6 +300,7 @@ var parseConfig = function (configFilePath, cliOptions) {
}

var config = new Config()
config.set(cliOptions)

try {
configModule(config)
Expand Down
9 changes: 9 additions & 0 deletions test/unit/config.spec.js
Expand Up @@ -38,6 +38,7 @@ describe('config', () => {
'/home/config4.js': wrapCfg({port: 123, autoWatch: true, basePath: '/abs/base'}),
'/home/config6.js': wrapCfg({reporters: 'junit'}),
'/home/config7.js': wrapCfg({browsers: ['Chrome', 'Firefox']}),
'/home/config8.js': config => config.set({ files: config.suite === 'e2e' ? ['tests/e2e.spec.js'] : ['tests/unit.spec.js'] }),
'/conf/invalid.js': () => { throw new SyntaxError('Unexpected token =') },
'/conf/exclude.js': wrapCfg({exclude: ['one.js', 'sub/two.js']}),
'/conf/absolute.js': wrapCfg({files: ['http://some.com', 'https://more.org/file.js']}),
Expand Down Expand Up @@ -144,6 +145,14 @@ describe('config', () => {
expect(config.browsers).to.deep.equal(['Safari'])
})

it('should have access to cli options in the config file', () => {
var config = e.parseConfig('/home/config8.js', {suite: 'e2e'})
expect(patternsFrom(config.files)).to.deep.equal([resolveWinPath('/home/tests/e2e.spec.js')])

config = e.parseConfig('/home/config8.js', {})
expect(patternsFrom(config.files)).to.deep.equal([resolveWinPath('/home/tests/unit.spec.js')])
})

it('should resolve files and excludes to overriden basePath from cli', () => {
var config = e.parseConfig('/conf/both.js', {port: 456, autoWatch: false, basePath: '/xxx'})

Expand Down

0 comments on commit 70cf903

Please sign in to comment.