在AngularJS教程中遇到问题的E2E测试处理
我正在进行AngularJS的教程,但在进行到E2E测试部分时遇到了错误。由于没有太多的日语支援,所以我写了这个问题。
错误内容
错误内容如下: (Chinese translation)
npm verb pkgid angular-phonecat@0.0.0
npm verb cwd /Users/*/angular-phonecat
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "protractor"
npm ERR! node v0.12.6
npm ERR! npm v2.11.2
npm ERR! code ELIFECYCLE
npm ERR! angular-phonecat@0.0.0 protractor: `protractor test/protractor-conf.js`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the angular-phonecat@0.0.0 protractor script 'protractor test/protractor-conf.js'.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor test/protractor-conf.js
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm verb exit [ 1, true ]
npm ERR! Please include the following file with any support request:
npm ERR! /Users/*/angular-phonecat/npm-debug.log
应对
当我尝试搜索一些东西时,有人指出可能没有指定chromeDriver。
首先,我尝试了以下方式。
-
- chromeDriverの取得
-
- protractor-conf.jsでchromeDriverのパス指定
- protractor-conf.jsにdirectConnect: trueを追加
获取Chrome驱动程序
执行以下命令
npm install chromedriver --chromedriver_cdnurl=http://npm.taobao.org/mirrors/chromedriver
在 protractor-config.js 文件中指定 chromeDriver 的路径。
请在/angular-phonecat/test/protractor-conf.js文件中添加以下内容。
chromeDriver: '../node_modules/chromedriver/bin/chromedriver',
在protractor-conf.js中添加directConnect: true。
在 /angular-phonecat/test/protractor-conf.js 中添加以下内容。
directConnect: true,
如果你运行npm run protractor,它应该会正常运行。
在执行之前,请在终端的另一个标签页或窗口中运行npm start。