使用量angular器给出错误进行端到端testing

我正在尝试通过angularjs.org的angular-phonecat中的教程。 在stetp三,我得到错误的量angular器端到端testing。 这是错误代码。

Using ChromeDriver directly... Cannot read property 'matcherFn_' of undefined [launcher] Runner Process Exited With Error Code: 1 npm ERR! angular-phonecat@0.0.0 protractor: `protractor test/protractor-conf.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the angular-phonecat@0.0.0 protractor script. 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 ERR! System Windows_NT 6.2.9200 npm ERR! command "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodej s\\node_modules\\npm\\bin\\npm-cli.js" "run" "protractor" npm ERR! cwd c:\angular-phonecat\angular-phonecat npm ERR! node -v v0.10.28 npm ERR! npm -v 1.4.9 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! c:\angular-phonecat\angular-phonecat\npm-debug.log npm ERR! not ok code 0 

这里出了什么问题?

这个问题似乎是由minijasminenode的最新1.0.0版本引起的。 作为一个临时的解决方法,这个黑客工作:

  • 编辑node_modules / protractor / package.json并将minijasminenode依赖关系更改为<1.0.0,现在读起来像这样:

“minijasminenode”:“<1.0.0”,

  • 删除minijasminenode目录:

rm -r node_modules / protractor / node_modules / minijasminenode

  • 重新安装所需的模块:

cd node_modules /量angular器&& npm安装

您的e2etesting现在应该运行。 实现这一点可能有一个更优雅的方式。

另见https://github.com/angular/protractor/issues/931

安德鲁的答案适合我。 谢谢安德鲁

顺便说一句,我也改变了'browserName':'chrome'到'browserName':'firefox',因为在我的linux系统中没有安装chrome。 然后它工作。

添加firefox使量angular器testing运行在我的Windows 7上,因为在Mac铬运行良好,这里是完整的testing/ protractor-conf.js文件

 exports.config = { allScriptsTimeout: 11000, specs: [ 'e2e/*.js' ], capabilities: { 'browserName': 'firefox' }, firefoxOnly: true, baseUrl: 'http://localhost:2000/', framework: 'jasmine', jasmineNodeOpts: { defaultTimeoutInterval: 30000 } }; 

我遇到了类似的问题,无论我在哪find哪个解决scheme。 当我通过XAMPP运行大部分项目时,发现我的问题是由于configuration页面上的端口设置错误导致的。

\testing\量angular器-config.js

  baseUrl: 'http://localhost:8383/', <-- Altered to suit xampp localhost port 

以前是

  baseUrl: 'http://localhost:8000/', 

希望这也能帮助别人。

我尝试了所有的解决scheme,但仍然有错误。 将主package.json文件中的量angular器版本更改为“〜0.20.1”,以便读取"protractor": "~0.20.1",并以pipe理员身份运行命令行。

第一次运行后,会出现ChromeDriver错误。 我解决了这个问题,只需将protractor-conf.js文件中的chromeOnly: True属性replace为驱动程序本身的完整path即可: chromeDriver: 'F:/Documents/Angular/angular-phonecat/node_modules/protractor/selenium/chromedriver_2.9.zip'

不太确定是否使用早期版本是个好主意。