問題
Angular真是一個很折騰人的框架,一天就遇到了兩問題月幌。
現(xiàn)在按照Angular中文網(wǎng)的步驟進(jìn)行單元測試時碍讯,又出現(xiàn)了問題。
首先我只想說這個網(wǎng)站的教程是多久以前的了扯躺,怎么源碼文件和教程的命令不同步的捉兴,真是無力吐槽。
回到正題录语,由于本網(wǎng)站的年代性倍啥,原先
.\scripts\test-server.bat
這些單元測試的命令是完全沒用了,因為根本不存在test-server.bat文件
解決辦法
再次感謝JavaChen's Blog寫的教程
在他的博客里面執(zhí)行
npm run protractor
就可以運行單元測試了澎埠。虽缕。 但是,問題又產(chǎn)生了蒲稳,執(zhí)行該命令后會出現(xiàn)如下錯誤
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn java ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:441:9)
at process._tickCallback (node.js:355:17)
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "F:\\Software\\nodejs\\node.exe" "F:\\Software\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "protractor"
npm ERR! node v4.2.6
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
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 '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 ERR! Please include the following file with any support request:
npm ERR! E:\項目\public\angular-phonecat\npm-debug.log
這才是一個最磨人的bug氮趋,找了很多解決辦法
- 更新谷歌瀏覽器
- 把protractor安裝成全局的
npm install -g protractor
但是很遺憾以上兩個辦法對我都無效,在即將放棄之際弟塞,居然找到了解決辦法凭峡,累死哥。
最終方法
把angular-phonecat\test下protractor-conf.js里的
chromeOnly: true
換成
directConnect: true
好了决记,再次啟動摧冀,問題完美解決