Search code examples
angularautomated-testskarma-jasmineangular-clikarma-webpack

angular-cli - Use multiple karma.conf.js


I am using angular-cli and I want to use two karma.conf.js files for testing.

  1. For CI : For which I am using Headless Chrome

    customLaunchers: {

      ChromeHeadless: {
        base: 'Chrome',
        flags: [
          '--headless',
          '--disable-gpu',
          // Without a remote debugging port, Google Chrome exits immediately.
          '--remote-debugging-port=9222',
        ],
      }
    }
    
  2. For Dev : For which I am using Chrome.

Is there any way that I could switch betwwen two karma.conf.js based on an argument value.


Solution

  • You can use option karmaConfig:

    ng test --karmaConfig=another-karma.config.json
    

    You may want to check ng test --help=true for other options.