简体   繁体   English

从grunt测试访问运行Chrome时出错

[英]Access error running chrome from grunt test

I am trying to run karma tests on my angular project. 我正在尝试在我的角度项目中进行业力测试。 I used yeoman to create the angular project. 我用yeoman创建了角度项目。 However when I am trying to run tests, I am getting following errors 但是,当我尝试运行测试时,出现以下错误

grunt test
Running "clean:server" (clean) task

Running "concurrent:test" (concurrent) task

Running "coffee:dist" (coffee) task

Running "coffee:test" (coffee) task

Done, without errors.

Running "connect:test" (connect) task
Started connect web server on localhost:9000.

Running "karma:unit" (karma) task
INFO [karma]: Karma server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/home/arpit/proj/proj1/views/test/mock/**/*.js" does not  
match any file.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
INFO [launcher]: Trying to start Chrome again.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES

INFO [launcher]: Trying to start Chrome again.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.

I can run chrome from bash using same account successfully with which I am trying to run grunt test Also, sudo grunt test is running fine. 我可以使用尝试运行grunt测试的同一帐户成功地从bash运行chrome,而且sudo grunt test运行正常。

On the Mac, it's important to set CHROME_CANARY_BIN to binary file, not just to app package. 在Mac上,重要的是将CHROME_CANARY_BIN设置为二进制文件,而不仅仅是应用程序包。

In my case, problem emerged from installing Chrome via brew cask , so I had to set 就我而言,问题是通过brew cask安装Chrome出现的,所以我不得不设置

export CHROME_CANARY_BIN="/opt/homebrew-cask/Caskroom/google-chrome-canary/latest/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"

In most cases you have to set a environment variable "CHROME_BIN" to point at your chrome.exe 在大多数情况下,您必须设置环境变量“ CHROME_BIN”以指向chrome.exe

Windows: 视窗:

set CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

Mac 10.7.5 Mac 10.7.5

I was able to set it using the following 我可以使用以下设置

export CHROME_BIN=/Applications/Chrome.app/Contents/MacOS/Google\\ Chrome 导出CHROME_BIN = / Applications / Chrome.app / Contents / MacOS / Google \\ Chrome

You get to the exec file by right clicking on the .app and selecting the Show Package Contents option. 通过右键单击.app并选择“显示包内容”选项,可以进入exec文件。 Follow this down to the executable and click it. 按照此步骤找到可执行文件,然后单击它。 It brought up the path in the terminal. 它带来了终端中的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM