由于“没有捕获的浏览器”消息,Karma没有运行unit testing
我试图设置噶运行使用茉莉花AngularJSunit testing,但我不能让testing运行。 我敢肯定,我忽略了一些简单的东西。 我在Windows 7机器上运行这个,并安装了Node.js
并通过npm
安装了karma。
我的目录结构如下所示:
- js / app / – 包含控制器,应用程序等
- js / config / – 包含karma.conf.js
- js / lib / – 包含angular
- js / test / – 包含茉莉花规格
我在js
目录中启动一个命令提示符并运行这个命令:
karma start config/karma.conf.js
这导致Chrome在端口9876上运行,但是每当我更改任何观看的文件并检查Karma输出时,我看到以下信息消息:
No captured browser, open http://localhost:9876/
这是我的configuration文件:
module.exports = function(config) { config.set({ basePath: '../', frameworks: ['jasmine'], files: [ 'lib/angular.js', 'app/**/*.js', 'test/**/*.js' ], exclude: [ ], reporters: ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], captureTimeout: 60000, singleRun: false }); };
我使用的是Angular 1.2.10和Karma 0.10.9
不过,我在不同的设置(Linux,QUnit,Firefox)中遇到了同样的问题。 我杀死了所有的业力进程后,问题消失了,做了一个新的karma start
。
这个错误可能意味着浏览器找不到服务器。 检查您是否可以通过所提到的URL访问服务器。 这可能是一个错误configuration的端口号,甚至(就像我的情况), localhost
被错误configuration。 我想这可能是服务器没有运行,或任何其他问题。
检查您是否可以手动联系服务器。 如果你不能,解决这个问题。
我有一个脸掌的时刻 。 karma start
需要在你的karma.conf.js
文件所在的目录下运行。
当我在我的代码中有一个无限循环时,这发生在我身上。 注释掉(在茉莉花中使用xdescribe
)我写的最近的代码得到了testing再次运行。
我有同样的问题,没有代码更改,只是重新运行一个月前工作的testing。
当我从webstorm
跑出来的webstorm
,似乎需要很长时间来捕捉浏览器,所以我想知道是否超时。
所以我试着将浏览器设置为Chrome
(我也使用phantomjs
),然后等待。 然后重置回Chrome
和PhantomJS
,现在没关系。
安装karma-cli npm install -g karma-cli
为我解决了这个问题。 希望这可以帮助。
我正在使用angular5,当scafold项目,并说恩testing说,npm安装–save-dev karma-phantomjs-launcher,:(
我有同样的问题,我做了所有人从这里说没有任何结果。 在我的情况下,我没有做的init:
C:\Users>cd c:\xampp\htdocs\angularjs-pro\ch07 c:\xampp\htdocs\angularjs-pro\ch07>karma init Which testing framework do you want to use ? Press tab to list possible options. Enter to move to the next question. > jasmine Do you want to use Require.js ? This will add Require.js plugin. Press tab to list possible options. Enter to move to the next question. > no Do you want to capture any browsers automatically ? Press tab to list possible options. Enter empty string to move to the next question. > Chrome
第二次,当我尝试在错误的文件夹做karma start
,而不是我把karma init
。
在这两种情况下,我解决了我在寡妇控制台中遇到的问题:
22 11 2016 14:06:51.697:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/ 22 11 2016 14:06:51.698:INFO [launcher]: Launching browser Chrome with unlimited concurrency 22 11 2016 14:06:51.711:INFO [launcher]: Starting browser Chrome 22 11 2016 14:06:53.936:INFO [Chrome 54.0.2840 (Windows 10 0.0.0)]: Connected on socket /#HnJUQrkRPqtGFa5ZAAAA with id 16058274