Search code examples
jasminekarma-runnerkarma-jasmine

Pass karma programmatically arguments


I am using karma with jasmine and the jasmine-spec-tags framework. When starting karma from CLI I use "karma start --tags=MY_TAG" to run only some tests with the tag MY_TAG. This works fine.

Now, I need to start karma programmatically. I tried the following code (note the client.args value at the end):

const server = new Server(
{
    autoWatch: true,
    browsers: [
        'Chrome',
    ],
    files: [
        './node_modules/babel-polyfill/dist/polyfill.js',
        './node_modules/es6-shim/es6-shim.min.js',
        './karma/karma.entry.js'
    ],
    frameworks: ['jasmine', 'jasmine-spec-tags'],
    phantomJsLauncher: {
        exitOnResourceError: true
    },
    port: 9876,
    preprocessors: {
        './karma/karma.entry.js': ['webpack', 'sourcemap']
    },
    reporters: ['dots'],
    singleRun: false,
    webpack: webpackConf,
    webpackServer: {
        noInfo: true
    },
    client:
    {
        args: ['--tags=SchedulingApiService']
    }
});

server.start();

This does not work. Am I misunderstanding the client.args value? Would be glad about any help.


Solution

  • To solve this, the client part has to look like this:

    client:
    {
        tags: 'SchedulingApiService'
    }