Karma test runner - fails to capture chrome

2019-05-25 09:01发布

问题:

I'm using Yeoman to generate an AngularJS app. Running the grunt serve to preiview my app works fine, but when i try to run the tests using grunt test I get the following error on my console:

Running "karma:unit" (karma) task
DEBUG [plugin]: Loading karma-* from D:\dev\wamp\www\tests\app\node_modules
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-coffee-preprocessor.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-html2js-preprocessor.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-ng-html2js-preprocessor.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-ng-scenario.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-requirejs.
DEBUG [plugin]: Loading plugin D:\dev\wamp\www\tests\app\node_modules/karma-script-launcher.
INFO [karma]: Karma v0.10.8 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
DEBUG [launcher]: Creating temp dir at C:\Users\shlomis\AppData\Local\Temp\karma-91802655
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\shlomis\AppData\Local\Temp\karma-91802655 --no-default-browser-check --no-first-run --disable-def
ault-apps --start-maximized http://localhost:8080/?id=91802655
WARN [watcher]: Pattern "D:/dev/wamp/www/tests/app/test/mock/**/*.js" does not match any file.
DEBUG [watcher]: Resolved files:
        D:/dev/wamp/www/tests/app/node_modules/karma-jasmine/lib/jasmine.js
        D:/dev/wamp/www/tests/app/node_modules/karma-jasmine/lib/adapter.js
        D:/dev/wamp/www/tests/app/app/bower_components/angular/angular.js
        D:/dev/wamp/www/tests/app/app/bower_components/angular-mocks/angular-mocks.js
        D:/dev/wamp/www/tests/app/app/scripts/app.js
        D:/dev/wamp/www/tests/app/app/scripts/controllers/main.js
        D:/dev/wamp/www/tests/app/test/spec/controllers/main.js
DEBUG [web-server]: serving: D:\dev\wamp\www\tests\app\node_modules\karma\static/client.html
DEBUG [web-server]: serving: D:\dev\wamp\www\tests\app\node_modules\karma\static/karma.js
DEBUG [karma]: A browser has connected on socket 1ozU-x__3w49R5zevWXm
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.
  • node v0.10.23
  • Karma version: 0.10.8

What am I missing?

回答1:

Changing the default port (8080) to 9876 in karma.conf.js file solved the issue for me