2017-06-30 18 views
0

私はWebサイトを開発しており、CircleCIで自動的にテストを実行したいと考えています。CircleCIのNightwatch.jsでE2Eテストを実行できますか?

テスト用の設定ファイルとjsファイルを書き、私のマシンのローカルでE2Eテストを実行しました。できます。

そして、CircleCIにcircleci.ymlとプロジェクトを作成しました。それは動作しません。

エラーログ

$ npm run test 

> [email protected] test /home/ubuntu/static_web_site 
> nightwatch 

Starting selenium server... started - PID: 17970 

[Test] Test Suite 
===================== 

Running: Demo test Google 

Error retrieving a new session from the selenium server 

Connection refused! Is selenium server started? 
{ state: 'session not created', 
    sessionId: null, 
    hCode: 537979030, 
    value: 
    { additionalInformation: '\nDriver info: driver.version: ChromeDriver', 
    localizedMessage: 'session not created exception: Chrome version must be >= 58.0.3029.0\n (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.13.0-119-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 746 milliseconds\nBuild info: version: \'3.4.0\', revision: \'unknown\', time: \'unknown\'\nSystem info: host: \'box2107\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.13.0-119-generic\', java.version: \'1.8.0_102\'\nDriver info: driver.version: ChromeDriver', 
    systemInformation: 'System info: host: \'box2107\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.13.0-119-generic\', java.version: \'1.8.0_102\'', 
    supportUrl: null, 
    cause: null, 
    suppressed: [], 
    message: 'session not created exception: Chrome version must be >= 58.0.3029.0\n (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.13.0-119-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 746 milliseconds\nBuild info: version: \'3.4.0\', revision: \'unknown\', time: \'unknown\'\nSystem info: host: \'box2107\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.13.0-119-generic\', java.version: \'1.8.0_102\'\nDriver info: driver.version: ChromeDriver', 
    hCode: 60610566, 
    class: 'org.openqa.selenium.SessionNotCreatedException', 
    buildInformation: 
     { buildRevision: 'unknown', 
     buildTime: 'unknown', 
     releaseLabel: '3.4.0', 
     hCode: 163722713, 
     class: 'org.openqa.selenium.internal.BuildInfo' }, 
    screen: null }, 
    class: 'org.openqa.selenium.remote.Response', 
    status: 33 } 

npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! [email protected] test: `nightwatch` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] test script. 
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 

npm ERR! A complete log of this run can be found in: 
npm ERR!  /home/ubuntu/.npm/_logs/2017-06-30T02_34_01_711Z-debug.log 

npm run test returned exit code 1 

package.json

{ 
    "name": "static_web_site", 
    "version": "0.0.0", 
    "description": "", 
    "scripts": { 
    "build": "rimraf dist && webpack", 
    "start": "webpack-dev-server -d --colors --inline --hot --port 4000 --host 0.0.0.0", 
    "test": "nightwatch", 
    "lint": "sass-lint -v -q && pug-lint app/**/*.pug" 
    }, 
    "keywords": [], 
    "author": "Allajah", 
    "license": "MIT", 
    "devDependencies": { 
    "babel-core": "^6.23.1", 
    "babel-loader": "^7.0.0", 
    "babel-plugin-add-module-exports": "^0.2.1", 
    "babel-polyfill": "^6.23.0", 
    "babel-preset-es2015": "^6.22.0", 
    "babel-register": "^6.24.1", 
    "chromedriver": "^2.30.1", 
    "copy-webpack-plugin": "^4.0.1", 
    "css-loader": "^0.28.0", 
    "extract-text-webpack-plugin": "^2.1.1", 
    "file-loader": "^0.10.1", 
    "html-webpack-plugin": "^2.28.0", 
    "nightwatch": "^0.9.16", 
    "node-sass": "^4.5.0", 
    "normalize.css": "^6.0.0", 
    "postcss-loader": "^2.0.6", 
    "pug": "^2.0.0-beta.12", 
    "pug-lint": "^2.4.0", 
    "pug-loader": "^2.3.0", 
    "rimraf": "^2.6.1", 
    "sass-lint": "^1.10.2", 
    "sass-loader": "^6.0.2", 
    "selenium-server-standalone-jar": "=3.4.0", 
    "style-loader": "^0.13.2", 
    "webpack": "^2.6.1", 
    "webpack-dev-server": "^2.4.1" 
    } 
} 

nightwatch.json

{ 
    "src_folders": ["test/e2e/"], 
    "output_folder": "test/reports/", 
    "custom_commands_path": "", 
    "custom_assertions_path": "", 
    "page_objects_path": "", 
    "globals_path": "node_modules/babel-register", 
    "selenium": { 
    "start_process": true, 
    "server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.4.0.jar", 
    "log_path": "test/logs", 
    "host": "127.0.0.1", 
    "port": 4444, 
    "cli_args": { 
     "webdriver.chrome.driver": "node_modules/.bin/chromedriver" 
    } 
    }, 
    "test_settings": { 
    "default": { 
     "launch_url": "http://localhost", 
     "selenium_port": 4444, 
     "selenium_host": "localhost", 
     "silent": true, 
     "screenshots": { 
     "enabled": true, 
     "on_failure": true, 
     "on_error": false, 
     "path": "test/screenshots" 
     }, 
     "desiredCapabilities": { 
     "browserName": "chrome", 
     "javascriptEnabled": true, 
     "acceptSslCerts": true 
     }, 
     "globals": { 
     "baseUrl": "http://localhost:4000", 
     "waitTime": 10000 
     }, 
     "use_xpath": false 
    } 
    } 
} 

テスト/ E2E/test.js

module.exports = { 
    tag: 'nightwatch test', 
    'test': (client) => { 
     client.url('http://www.google.com').waitForElementVisible('body', 1000).assert.title('Google').assert.visible('input[type=text]').end() 
    } 
} 

circle.yml

machine: 
    node: 
    version: 7.4.0 
environment: 
    PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin" 
dependencies: 
    pre: 
    - npm i -g npm 
test: 
    override: 
    - npm run build 
    - npm run start: 
     background: true 
    - sleep 10 
    - npm run test 

私はhttps://github.com/beatfactor/nightwatch-circleciを参照するこれらのスクリプトを書きました。 そして、私はそれをフォークし、CircleCIでテストを実行しようとしましたが、うまく動作しませんでした。

誰かがCircleCIのNightwatch.jsでE2Eテストを実行するのに役立ちますか?

ありがとうございました:)

答えて

0

CircleCIでChromeを更新するだけで済みます。

Seleniumのエラーは、Chromeが少なくともバージョン58以上であることを期待していると述べています。default Ubuntu imagesはChromeの古いバージョン(またはそれ以前のバージョン)を使用しています。この問題を解決するには

、あなたの依存関係をインストールするときに、あなたのcircle.ymlにこれらのステップを追加します。

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' 
sudo apt-get update 
sudo apt-get --fix-broken --only-upgrade install google-chrome-stable 
関連する問題