How to make travis execute Angular tests on Chrome (“Please set env variable CHROME_BIN”)

前端 未结 4 1003
终归单人心
终归单人心 2020-12-08 02:58

I\'m working on a sample Angular project generated by yeoman.
I am able to run karma tests locally (I set system variable CHROME_BIN to point to chromium bi

4条回答
  •  情话喂你
    2020-12-08 03:26

    Use this solution to get it running using the preinstalled Chromium Version in Travis-CI VM: https://github.com/karma-runner/karma/issues/1144#issuecomment-53633076

    .travis.yml

      node_js:
      - "0.10"
    
    script: node_modules/karma/bin/karma start test/karma.conf.js --single-run
    
    before_install:
      - export CHROME_BIN=chromium-browser
      - export DISPLAY=:99.0
      - sh -e /etc/init.d/xvfb start
    

    karma.conf.js

    module.exports = function(config) {
      var configuration = {
    
        /* ... */
    
        // start these browsers
        browsers: ['Chrome', 'ChromeCanary'],
    
        customLaunchers: {
          Chrome_travis_ci: {
            base: 'Chrome',
            flags: ['--no-sandbox']
          }
        },
    
        /* ... */
    
      };
    
      if(process.env.TRAVIS){
        configuration.browsers = ['Chrome_travis_ci'];
      }
    
      config.set(configuration);
    };
    

提交回复
热议问题