Karma/Jasmine 超时而不运行测试 [英] Karma/Jasmine times out without running tests

查看:22
本文介绍了Karma/Jasmine 超时而不运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个由 Grunt 生成的项目上运行 Karma/Jasminehttp://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/

I'm trying to run Karma/Jasmine from Grunt on a project generated with http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/

Karma 启动 PhantomJS(或 Chrome),并且根据 singleRun,它要么超时,要么只是坐在那里什么也不做.我已经尝试根据从有类似问题的人那里读取解决方案来更改 captureTimeoutbrowserNoActivityTimeout,但它似乎不起作用.

Karma launches PhantomJS (or Chrome) and, depending on singleRun, it either times out or just sits there and does nothing. I've tried changing captureTimeout and browserNoActivityTimeout based on reading solutions from people with similar problems, but it doesn't seem to work.

我的相关软件包版本等:

My relevant pacakge versions etc.:

  • 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 上有同样的问题:

我已尝试将所有开发依赖项更新到最新版本,但问题仍然存在.

I've tried updating all my dev dependencies to the latest versions but the problem still remains.

我的控制台输出如下.引用 bundle is VALID/INVALID 的 webpack 行令人担忧,但我找不到任何关于它们含义的信息.这是我的控制台输出:

My console output is below. The webpack lines referring to bundle is now VALID/INVALID are worrying, but I can't find any info on what they mean. Here's my console output:

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
});
};

推荐答案

我遇到了同样的问题.从相关的 GitHub 问题 中,我了解到您可以延长不活动超时时间.

I had the same problem. From a related GitHub Issue, I learned that you can extend the inactivity timeout.

在您的 gruntfile 或 karma 配置文件中设置此 Karma 配置选项:

Set this Karma config option in your gruntfile or karma config file:

browserNoActivityTimeout: 100000

我将其设置为 100 秒并且我的测试成功运行.我不知道是什么导致了延迟.

I set it to 100 seconds and my tests ran successfully. I don't know what's causing the delay.

这篇关于Karma/Jasmine 超时而不运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆