Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testing Angular apps with Protractor
Search
Tomohiro Akutsu
June 18, 2017
Programming
0
1.3k
Testing Angular apps with Protractor
angularを使用したwebアプリケーションにおけるE2Eテストに関するスライドです。また、こちらは2017年6月16日に行われたD-cubeの資料となっています。
Tomohiro Akutsu
June 18, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
500
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
6
1.6k
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
1
580
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
48
31k
GoのGenericsによるslice操作との付き合い方
syumai
3
690
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
940
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
310
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
200
5つのアンチパターンから学ぶLT設計
narihara
1
120
PicoRuby on Rails
makicamel
2
110
WebViewの現在地 - SwiftUI時代のWebKit - / The Current State Of WebView
marcy731
0
100
Node-RED を(HTTP で)つなげる MCP サーバーを作ってみた
highu
0
110
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Six Lessons from altMBA
skipperchong
28
3.9k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
Adopting Sorbet at Scale
ufuk
77
9.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
The Cult of Friendly URLs
andyhume
79
6.5k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Building an army of robots
kneath
306
45k
Bash Introduction
62gerente
614
210k
Faster Mobile Websites
deanohume
307
31k
Docker and Python
trallard
44
3.4k
Transcript
Testing ɹngular apps with Protractor June 2017 v.1.0.0 Tomohiro Akutsu
Front-end Engineer BizReach, Inc. June 16 2017 @Bizreach, Inc.
Introduce Myself - ࣗݾհ -
## Introduce Myself Tomohiro Akutsu Ѩٱஐେ @TomohiroAkutsu HRMOS Div. BizReach,
Inc. Front-end Engineer
Introduce Our Product - )3.04ͷհ -
## Introduce Our Product https://hrmos.co/
Agenda - ຊ͓͢Δ͜ͱ -
## Agenda ### E2E Testing and Protractor ### Install and
Setup ### API/Usage ### Resource of Learning 1SPUSBDUPSͷ֓ཁ 1SPUSBDUPSͷΠϯετʔϧɺ$POGKTͷهड़ ༻ҙ͞Ε͍ͯΔ"1*ه๏ ࠓޙɺΑΓࣝΛਂΊΔ͋ͨͬͯ
Do not Talk - ຊ͓͠ͳ͍͜ͱ -
## Do not Talk ### Unit Testing of Front-end ###
Comparison with Other Testing Framework ϑϩϯτΤϯυʹ͓͚ΔϢχοτςετ ଞͷςετπʔϧͱͷൺֱݕ౼
E2E Testing and Protractor - Protractorͷ֓ཁ -
## Introduce Protractor http://www.protractortest.org/#/
## Introduce Protractor https://github.com/angular/protractor
## Overview of Protractor ɾ1SPUSBDUPSثͷҙຯΛ࣋ͭ ɾͪͳΈʹBOHVMBS֯ͷ͋ΔΈ͍ͨͳҙຯ ɾBOHVMBS ֯ Λςετ ଌΔ
͢Δ1SPUSBDUPS ث ɾ/PEFKT͔Β4FMFOJVNΛѻ͏ϥΠϒϥϦͱͯ͠8FC%SJWFS+4Λར༻
## Built on top of WebDriverJS https://www.thoughtworks.com//insights/blog/testing-angularjs-apps-protractor
Install and Setup - ProtractorͷΠϯετʔϧɺConf.jsͷهड़ -
## Install OQNͰ1SPUSBDUPSΛΠϯετʔϧ npm install protractor QSPUSBDUPS XFCESJWFSNBOBHFSίϚϯυ͕͑ΔΑ͏ʹͳΔɻ 4FMFOJVN8FC%SJWFSΛϩʔΧϧڥΠϯετʔϧ webdriver-manager
update αʔόʔͷىಈ webdriver-manager start IUUQMPDBMIPTUXEIVCͷΞΫηε͕ՄೳʹͳΔɻ
## Example QBDLBHFKTPOͷTDSJQUTʹهड़ “scripts”: { … “test”: “protractor ./test/protractor/conf.js”, “webdriver”:
“webdriver-manager update && webdriver-manager start”, … } ίϚϯυͰςετͷ࣮ߦ͕Մೳɻҙͱͯͦ͠ΕͧΕผλϒͰ։͘͜ͱɻ
## Setup DPOGKTʹ֤छઃఆΛهड़ɹhttps://github.com/angular/protractor/blob/master/lib/config.ts export.config = { seleniumAddress: ‘http://localhost:4444/wd/hub’, capabilities: {
‘browserName’: ‘chrome’ }, specs: [spec.js], baseUrl: ‘http://localhost:9000/’, jasminNodeOpts: { showColors: true, defaultTimeoutInterval: 30000 } };
API/Usage - ༻ҙ͞Ε͍ͯΔAPIه๏ -
Basic Example - spec.jsͷجຊతͳߏจ -
## Basic Example spec.js describe(‘this test description is Hoge.’, function()
{ it(‘Fuga in Hoge’, function() { browser.get(‘https://angular.io/’); expect(browser.getTitle()).toEqual(‘Angular Docs’); }); it(‘Piyo in Hoge’, function() { … }); });
Global Variables - άϩʔόϧม -
## browser browser.get(‘url’) var baseUrl = ‘http://localhost:3000’; … browser.get(baseUrl +
‘/path/’); expect(browser.getTitle()).toEqual(‘This page title is Hoge’); browser.waitForAngular() browser.waitForAngular();
## element, by <p class=“name”>My name is {{person.name}}.</p> <input type=“text”
ng-model=“person.name”> var input = element(by.model(‘person.name’)); input.sendKeys(‘Tomohiro’); expect(element(by.css(‘p.name’)).getText()).toEqual(‘…is Tomohiro.’); element(by.model(‘modelName’)); <ul> <li>Blue</li> <li>Green</li> <li>Yellow</li> </ul> var yellow = element(by.cssContainingText(‘li’, ‘Yellow’)); element(by.cssContainingText(‘cssSelector’, ‘searchString’));
## element, by <ul ng-repeat=“item in items”> <li>{{item.name}}</li> </ul> element(by.repeater(‘item
in items’)).row(0).column(‘name’); element(by.repeater(‘repeatDescriptor’)); <a href=“url” class=“button”>Click</a> var button = element(by.className(‘button’)); expect(button.getText()).toEqual(‘Click’); button.click(); element(by.className(‘className’));
Handling Events - Πϕϯτͷॲཧ -
## Handling Events .click(); <button ng-click=“submit()”>submit</button> element(by.css(‘[ng-click=“submit()”]’)).click(); sendKeys(); var inputMail
= element(by.model(‘modelName’)); inputText.sendKeys(‘
[email protected]
’, protractor.Key.ENTER);
Resource of Learning - ࠓޙΑΓࣝΛਂΊΔ͋ͨͬͯ -
## Resource of Learning ɾެࣜυΩϡϝϯτ ɾ(JU)VC ɾ1SPUSBDUPS"OHVMBS+4ͷ࣍ੈ&&ςετϑϨʔϜϫʔΫ ɾ"OHVMBS+4ʹ&&ςετڥͱͯ͠1SPUSBDUPSΛಋೖ͢Δɻ
Thank You for Listening. - Let’s Work Together! -