How can I configure Karma to open a browser with command line arguments?

后端 未结 2 711
南方客
南方客 2021-02-07 08:34

I\'m using the Karma Test Runner and I\'ve configured it to use Chrome and PhantomJS like this:

browsers = [\'Chrome\', \'PhantomJS\'];

How can I configure Karma

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 08:49

    Something like this should work:

    // karma.conf.js
    module.exports = function(config) {
      config.set({
        browsers: ['Chrome_without_security','PhantomJS_without_security'],
    
        // you can define custom flags
        customLaunchers: {
          Chrome_without_security: {
            base: 'Chrome',
            flags: ['--disable-web-security']
          },
          PhantomJS_without_security: {
            base: 'PhantomJS',
            flags: ['--web-security=no']
          }
        }
      });
    };
    

    More information here: https://github.com/karma-runner/karma-chrome-launcher#configuration

提交回复
热议问题