Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
955 views
in Technique[技术] by (71.8m points)

angularjs - How to make travis execute Angular tests on Chrome ("Please set env variable CHROME_BIN")

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 binary, but this could have been done in more elegant way. Just a quick work-around.)

However, when attempting to produce a successful build with travis, I get following error:

ERROR [launcher]: Cannot start Chrome
    Can not find the binary google-chrome
    Please set env variable CHROME_BIN

I've followed the steps described here (basically using generator-travis-ci)
Then tried to fix it with this - got another error:
/home/travis/build.sh: line 142: ./.travis/scripts/install_chrome.sh: Permission denied


It's a standard angular app created with Yeoman - things should work out of the box, whereas reality is different ...
Has anybody successfully configured it?


Software versions I've been using:
user@machine:~/somewhere $ yo -v; grunt --version; bower -v
1.0.4
grunt-cli v0.1.9
grunt v0.4.1
1.2.6

my Travis job: https://travis-ci.org/vucalur/editor-yeoman-test

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);
};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...