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

后端 未结 2 713
南方客
南方客 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:43

    One solution I found, which may not be the most elegant, is to actually modify Karma's launcher scripts for each browser. This has solved the problem.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题