我正在尝试使用http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/生成的项目从Grunt运行Karma/Jasmine
Karma推出PhantomJS(或Chrome),并且根据singleRun,它要么超时要么只是坐在那里什么都不做.我尝试过改变captureTimeout
并browserNoActivityTimeout
基于阅读有类似问题的人的解决方案,但它似乎没有用.
我的相关pacakge版本等:
NodeJS:0.10.25
业力:0.12.16
Webpack:1.1.11
webpack-dev-server:1.4.1
因果茉莉:0.1.5
Linux:Ubuntu 14.04
我在OS X上发现有同样问题的人:
我已经尝试将所有dev依赖项更新到最新版本,但问题仍然存在.
我的控制台输出如下.引用bundle的webpack行现在是VALID/INVALID令人担忧,但我找不到任何关于它们含义的信息.这是我的控制台输出:
Running "karma:unit" (karma) task DEBUG [config]: autoWatch set to false, because of singleRun DEBUG [plugin]: Loading karma-* from /home/ed/workspace/wwb-app/node_modules DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-chrome-launcher. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-coffee-preprocessor. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-firefox-launcher. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-html2js-preprocessor. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-jasmine. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-phantomjs-launcher. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-requirejs. DEBUG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-script-launcher. DEBG [plugin]: Loading plugin /home/ed/workspace/wwb-app/node_modules/karma-webpack-plugin. INFO [karma]: Karma v0.12.16 server started at http://localhost:8080/ INFO [launcher]: Starting browser PhantomJS DEBUG [temp-dir]: Creating temp dir at /tmp/karma-98204612 DEBUG [launcher]: /home/ed/workspace/wwb-app/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-98204612/capture.js Hash: 89285186567c1bc5bb7f Version: webpack 1.1.11 Time: 2ms Asset Size Chunks Chunk Names webpack: bundle is now VALID. webpack: bundle is now INVALID. DEBUG [web-server]: serving: /home/ed/workspace/wwb-app/node_modules/karma/static/client.html DEBUG [web-server]: serving: /home/ed/workspace/wwb-app/node_modules/karma/static/karma.js DEBUG [web-server]: upgrade /socket.io/1/websocket/CjC8pnQq5It2z_kWYB98 DEBUG [karma]: A browser has connected on socket CjC8pnQq5It2z_kWYB98 INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket CjC8pnQq5It2z_kWYB98 with id 98204612 DEBUG [launcher]: PhantomJS (id 98204612) captured in 1.704 secs WARN [PhantomJS 1.9.7 (Linux)]: Disconnected (1 times), because no message in 30000 ms. DEBUG [karma]: Run complete, exitting. DEBUG [launcher]: Disconnecting all browsers DEBUG [launcher]: Process PhantomJS exited with code 0 DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-98204612 Warning: Task "karma:unit" failed. Use --force to continue. Aborted due to warnings.
这是我的karma.conf.js
档案:
'use strict'; module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine'], files: [ 'test/helpers/**/*.js', 'test/spec/components/**/*.js' ], preprocessors: { 'test/spec/components/**/*.js': ['webpack'] }, webpack: { cache: true, module: { loaders: [{ test: /\.css$/, loader: 'style!css' }, { test: /\.gif/, loader: 'url-loader?limit=10000&minetype=image/gif' }, { test: /\.jpg/, loader: 'url-loader?limit=10000&minetype=image/jpg' }, { test: /\.png/, loader: 'url-loader?limit=10000&minetype=image/png' }, { test: /\.js$/, loader: 'jsx-loader' }] } }, webpackServer: { stats: { colors: true } }, exclude: [], port: 8080, logLevel: config.LOG_DEBUG, colors: true, autoWatch: true, // Start these browsers, currently available: // - Chrome // - ChromeCanary // - Firefox // - Opera // - Safari (only Mac) // - PhantomJS // - IE (only Windows) browsers: ['PhantomJS'], reporters: ['progress'], captureTimeout: 60000, browserNoActivityTimeout: 60000, singleRun: true }); };
Matthias Dai.. 44
我有同样的问题.从相关的GitHub问题中,我了解到您可以延长不活动超时.
在gruntfile或karma配置文件中设置此Karma配置选项:
browserNoActivityTimeout: 100000
我将它设置为100秒,我的测试成功运行.我不知道造成延误的原因.
我有同样的问题.从相关的GitHub问题中,我了解到您可以延长不活动超时.
在gruntfile或karma配置文件中设置此Karma配置选项:
browserNoActivityTimeout: 100000
我将它设置为100秒,我的测试成功运行.我不知道造成延误的原因.
我已将我的Karma配置更改为
captureTimeout: 60000, // it was already there browserDisconnectTimeout : 10000, browserDisconnectTolerance : 1, browserNoActivityTimeout : 60000,//by default 10000
此外,我有200-300个测试,PhantomJS 1.9.8并且它只需要大约100 MB的幻像内存用于咕噜声和业力他们都使用了大约300mb的内存.
我们在构建服务器上遇到了类似的问题.
增加browserNoActivityTimeout工作到了一定程度.我们将其增加到60000毫秒,但随着单元测试数量的增加,phantomJS无法断开连接的问题又回来了.
我们最终将问题追溯到phantomJS可用的RAM.我们进行了1100次单元测试,需要大约1m30才能运行,但是phantomJS在60000ms超时内无法断开连接.
构建节点VM RAM从2GB增加到4GB,然后1100单元测试运行大约45s,phantomJS将与~5s断开连接.一个巨大的进步.
有两个教训:1.PhantomJS是内存耗尽的,所以确保它有足够的RAM来做它的事情2.分析你的代码,以了解你可以更高效地使用内存.
另一个可能的解释是RequireJS妨碍了.如果我将'requirejs'添加到config.frameworks数组中的karma.conf.js,我会收到这个确切的错误.这似乎覆盖了本机require函数,导致测试无法执行.在我的情况下,describe-block被触发,但是如果它是块,则没有.