Contenu connexe Similaire à pairsでのAngularJS x TypeScript x e2e @めぐすた#1 (20) pairsでのAngularJS x TypeScript x e2e @めぐすた#1 3. Copyright © 2009-2015 eureka, inc. All rights reserved.
なまえ Takuma Morikawa
しょぞく
たんとう (Go, JS, たまにインフラ)
じこしょうかい
32. $ jshint
hoge.js: line 17, col 187, Line is too long.
hoge.js: line 25, col 174, Line is too long.
hoge.js: line 27, col 126, Line is too long.
hoge.js: line 31, col 126, Line is too long.
hoge.js: line 145, col 124, Line is too long.
hoge.js: line 22, col 42, Expected '===' and instead saw '=='.
hoge.js: line 24, col 44, Expected '===' and instead saw '=='.
hoge.js: line 306, col 11, Missing semicolon.
…
Why TypeScript?
72. app/
- 機能群/
- ログイン/
- 検索/
- controller/
- service/
- directive/
- routing.ts
- 共通ライブラリ/
- e2eテスト/
AngularJS directory structure
73. AngularJS route
module pairs.search {!
!angular.module('pairs.search', [!
! !'ui.router',!
! !'ipCookie',!
!]).config([!
! !'$stateProvider', !
! !'$urlRouterProvider', !
! !'$locationProvider', !
! !states!
!]).service('SearchService', [!
! !'HttpService', !
! !'$q', !
! !'ipCookie', !
! !SearchService!
!]).controller(controller)!
!.directive(directive);!
74. AngularJS route
!function states(!
! !$stateProvider: ng.ui.IStateProvider,!
! !$urlRouterProvider: ng.ui.IUrlRouterProvider,!
! !$locationProvider: ng.ILocationProvider!
!) {!
! !$stateProvider!
! ! !.state('search', {!
! ! ! !url: '^/search/:type/{page:int}',!
! ! ! !controllerAs: 'ctrl',!
! ! ! !controller: controller.SearchController,!
! ! ! !templateUrl: '/search/hoge'!
! ! !});!
!}
87. 【ディレクトリ構成】
- 機能テスト/ // 単体テスト
- シナリオテスト/ // 結合テスト
- ページオブジェクト/
- ログインページ/
- 検索ページ/
- helper.js
- config.js
AngularJS protractor directory
88. 【ディレクトリ構成】
- 機能テスト/ // 単体テスト
- シナリオテスト/ // 結合テスト
- ページオブジェクト/
- ログインページ/
- 検索ページ/
- helper.js
- config.js
AngularJS protractor directory
90. AngularJS page object
var LoginPage = function() {!
!// ログインボタンのエレメント!
this.loginButton = element(by.id('login'))!
!
!// ログインページを開く!
this.open = function(){!
browser.get('/#/login');!
}!
!
!// ログインボタンを押下する!
this.clickLoginButton = function(){!
var loginButton = new LoginPage().loginButton;!
return browser.wait(function(){!
return loginButton.isPresent();!
}).then(function(){!
return loginButton.click();!
});!
};!
};!
module.exports = new LoginPage();
91. 【ディレクトリ構成】
- 機能テスト/ // 単体テスト
- シナリオテスト/ // 結合テスト
- ページオブジェクト/
- ログインページ/
- 検索ページ/
- helper.js
- config.js
AngularJS protractor directory
92. AngularJS helper
// time_helper.js!
!
var TimeHelper = function(){!
!// 現在のUNIXTIMEを取得する!
!this.getCurrentUnixtime = function(){!
! !return Math.floor(new Date/1000);!
!};!
!!
};!
!
module.exports = TimeHelper;
93. AngularJS helper
// helper.js!
!
var Helper = function(){};!
!
// 外部で定義したヘルパー関数をHelperへ詰め込む(mixin的な?)!
require('./time_helper').call(Helper.prototype);!
require('./selectbox_helper').call(Helper.prototype);!
require('./hoge_helper').call(Helper.prototype);!
!
module.exports = new Helper();
94. AngularJS page object w/ helper
// login.po.js!
!
var LoginPage = function() {!
// load helper!
!var helper = require('../helper');!
!// 都道府県のセレクトボックス !
this.stateSelect = element(by.model('vm.state_id'));!
!
!// セレクトボックスから指定した都道府県を選択する!
this.selectStateByName = function(name){!
var el = new LoginPage().stateSelect;!
helper.selectDropdownByText(el, name);!
}!
};!
!
module.exports = new LoginPage();
114. AngularJS e2e w/ CI
// circle.yml!
!
test:!
override:!
!# Goのテスト!
- gvm use stable; ginkgo -tags=tests -r . -cover!
!# メインのe2e!
- gulp e2e!
- sleep 2!
!# ログインページ その1!
- gulp e2e:login_success!
- sleep 2!
!# ログインページ その2!
- gulp e2e:login_error1!
- sleep 2!
!# ログインページ その3!
- gulp e2e:login_error2