LoginSignup
6
6

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-10-01

前提

Yeoman + AngularJS Generatorを使って構築し、Gruntfile.jsをGruntfile.coffeeへ書き換えた環境を前提としています。

yo anguar --coffee

Gruntfile.coffeeに関してはこちらをどうぞ
http://qiita.com/rneuo/items/c7d449a7361fe9cea236#2-3

概要

インストールモジュール説明

AngularJS + CoffeeScript + Protractor + Gruntでテスト環境を構築するにあたって、下記のnodeモジュールを使って構築してみたいと思います。

テスト実行環境

下記のようにSeleniumサーバーとProtractor内のBrower Driversによってテストスクリプトを実行します。

 [Test Scripts] < -- > [Selenium Server] < -- > [Browser Drivers]
    protractor             port:4444                 port:9001
        ↓                                       chrome browserのdriver
     jasmine

  • Test Scripts
    • e2e用のspecファイル
    • protractorを使用してspecファイルを記述
  • Selenium Server
    • protractorにバンドルされているSelenium Webdriverサーバーを使用する
  • Browser Drivers
    • protractorにバンドルされているChrome Driverを使用する

インストール

npm install protractor --save-dev
npm install protractor-coffee-preprocessor --save-dev
npm install grunt-protractor-runner --save-dev
npm install grunt-protractor-webdriver --save-dev
node_modules/protractor/bin/webdriver-manager update

package.jsonの末尾のscriptsの項目を下記のように書き換える。次回からnpm installで更新できるようにする

package.json
  "scripts": {
    "test": "grunt test",
    "install": "node_modules/protractor/bin/webdriver-manager update"
  }

その他の設定

yo angular --coffeeし、Gruntfile.coffeeへ変換した後の差分はこちらをどうぞ

連絡

いろんなやり方があると思いますが、よく見るやり方で色々はまってしまいました、、
上記のやり方ですんなりいったのですが、もっといい方法があれば是非コメントよろしくお願いします!

6
6
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
6
6