Last active
April 4, 2016 07:23
-
-
Save igara/d040292f43f88384c7b7 to your computer and use it in GitHub Desktop.
Protractor + mocha + power-assert + TypeScriptを用いてOnsenUIで作成したサイトのE2Eテスト ref: http://qiita.com/igara/items/15fd40241b9d702648b1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.config = { | |
| seleniumAddress: 'http://127.0.0.1:4444/wd/hub', | |
| framework: 'mocha', // mochaを使用する | |
| mochaOpts: { // mochaの設定 | |
| ui: 'bdd', // テスト記述方法をビヘイビアで行う。tddも可能 | |
| reporter: 'dot', // テスト結果出力方法。詳しくはhttps://mochajs.org/#reporters | |
| slow: 3000, | |
| enableTimeouts: false // テスト中にタイムアウトさせるかの設定 | |
| }, | |
| specs: ['tests/**/*.js'], // テスト対象ファイル | |
| capabilities: { | |
| 'browserName': 'chrome' // 使用ブラウザ | |
| }, | |
| baseUrl: 'http://127.0.0.1:8000/' | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typings install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| browser.actions() | |
| .mouseMove(body, {x:browserSize.width / 2, y:browserSize.height / 2}) | |
| .mouseDown() | |
| .mouseMove(body, {x:browserSize.width, y:browserSize.height / 2}) | |
| .mouseUp() | |
| .perform(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ブラウザ内のJavaScriptを実行させる | |
| browser.executeAsyncScript(function() { | |
| var callback = arguments[arguments.length - 1]; | |
| callback(menu.isMenuOpened()); | |
| }).then(function(isMenu) { | |
| assert.default( | |
| isMenu === true, | |
| 'error:サイドメニューが開かれていない'); | |
| // スリープさせる | |
| browser.sleep(sleepTime); | |
| // スクリーンショットを取る | |
| browser.takeScreenshot().then(function(data) { | |
| fs.writeFile( | |
| 'screenshot/syonetwork/OpenedSideMenu.png', | |
| data.replace(/^data:image\/png;base64,/,''), | |
| 'base64', | |
| function(error) { | |
| if(error) throw error; | |
| } | |
| ); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node_modules/protractor/bin/webdriver-manager update | |
| node_modules/protractor/bin/webdriver-manager start | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node_modules/.bin/protractor e2echrome.js | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.0.1", | |
| "private": true, | |
| "devDependencies": { | |
| "angular": "^1.5.0", | |
| "mocha": "^2.4.5", | |
| "onsenui": "^2.0.0-beta", | |
| "power-assert": "^1.2.0", | |
| "protractor": "^3.1.1", | |
| "typescript": "^1.8.0", | |
| "typings": "^0.6.7" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "ambientDependencies": { | |
| "angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#17ef40452039d19e06dc2a3815ea898c505860fa", | |
| "angular-protractor": "github:DefinitelyTyped/DefinitelyTyped/angular-protractor/angular-protractor.d.ts#17fa1e5f269189f7f8e0f53f8c443e6c2eac562c", | |
| "empower": "github:DefinitelyTyped/DefinitelyTyped/empower/empower.d.ts#aeb7701fbef3b7fc7261d67c025c823666ab98ea", | |
| "jquery": "github:igara/DefinitelyTyped/jquery/jquery.d.ts#144ca38f83058b29f2b7b38c28e931a0139aa022", | |
| "mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617", | |
| "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#263705d313346e093d95cb62cef6fed848e46978", | |
| "onsenui": "github:DefinitelyTyped/DefinitelyTyped/onsenui/onsenui.d.ts#76352a94c6e4a51e7f382aebaf0b63d9ac06ae12", | |
| "power-assert": "github:DefinitelyTyped/DefinitelyTyped/power-assert/power-assert.d.ts#695da95a2405a9d6aae11944174227e1e7716e37", | |
| "power-assert-formatter": "github:DefinitelyTyped/DefinitelyTyped/power-assert-formatter/power-assert-formatter.d.ts#aeb7701fbef3b7fc7261d67c025c823666ab98ea", | |
| "selenium-webdriver": "github:DefinitelyTyped/DefinitelyTyped/selenium-webdriver/selenium-webdriver.d.ts#a83677ed13add14c2ab06c7325d182d0ba2784ea" | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment