12
11

More than 5 years have passed since last update.

Protractor + PhantomJS + Grunt + AngularJSでE2Eテスト環境構築

Last updated at Posted at 2014-10-03

前提

PhantomJSはブラウザを起動させずにtestを実行させるためのものです。

今回は、以前投稿したAngularJS + CoffeeScript + Protractor + GruntでE2Eテスト環境構築のbrowser driverをPhantomJSに変更するだけです。

インストール

npm install phantomjs --save-dev

設定

以前投稿したAngularJS + CoffeeScript + Protractor + GruntでE2Eテスト環境構築からの修正点です。

備考

PhantomJSではブラウザが起動しないので、もしもうまくレンダリングなどが実行されていない場合、かなりはまる事になります。

なので、もしエラーが出てそうならtest/protractor.conf.jsをいったんchromeを起動するように戻す(要はAngularJS + CoffeeScript + Protractor + Gruntの環境)
一旦ブラウザを起動させエラーが出てればその時点でブラウザを閉じずにストップさせるように以下のようにtest/protractor.conf.jsを書き換えて後はconsoleにエラーが出てないか確認するといいのではと思います。

test/protractor.conf.js
capabilities: {
 'browserName': 'chrome',
 'chromeOptions': {
   'excludeSwitches': ['ignore-certificate-errors']
 }
},
onPrepare: function() {
  jasmine.getEnv().afterEach(function () {
    var spec = jasmine.getEnv().currentSpec;
    if (spec.results().failedCount > 0) {
      browser.pause();
    }
  });
}
12
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
11