浏览器与 Karma Runner 设置依赖断开连接

Browser disconnecting with Karma Runner setting dependence

我在我的环境中使用 karma runner 时遇到问题。

在我设置下划线的依赖之前,它一直很好:

NFO [watcher]: Changed file "/test/test-main.js". INFO [karma]: Delaying execution, these browsers are not ready: Chrome 40.0.2214 (Mac OS X 10.10.1)

当我 运行 没有下划线的测试时,一切都很好。

这是我的 test-main:

var tests = [];
for (var file in window.__karma__.files) {
  if (window.__karma__.files.hasOwnProperty(file)) {
    if (/Spec\.js$/.test(file)) {
      tests.push(file);
    }
  }
}

requirejs.config({

    baseUrl: '/base/src',

    deps: tests,
    callback: window.__karma__.start,

    paths: {
        'jquery': '../lib/jquery',
        'jasmine-jquery': '../test/lib/jasmine-jquery',
        'underscore' : '../lib/underscore',
        'handlebars' : '../lib/handlebars'
    },

     shim: {
       'jasmine/jasmine-jquery': {
            exports: 'jasmine-jquery'
       },
       'handlebars': {
            exports: 'Handlebars'
        },
        'underscore': {
            exports: '_'
        }
    }
});

我也尝试过不为下划线配置 shim,但出现了同样的错误。

我的karma-conf:

module.exports = function(config) {
  config.set({
    basePath: '',

    frameworks: ['jasmine', 'requirejs'],

    files: [
      'test/test-main.js',
      {pattern: 'test/fixtures/*.html', included: false, served: true },
      {pattern: 'test/lib/**/*.js ', included: false},
      {pattern: 'lib/**/*.js ', included: false},
      {pattern: 'src/**/*.js', included: false},
      {pattern: 'test/**/*Spec.js', included: false}
    ],

    exclude: [
      'src/main.js'
    ],

    preprocessors: {
    },
    reporters: ['progress'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_INFO,

    autoWatch: true,

    browsers: ['Chrome'],

    singleRun: false,

    browserDisconnectTimeout: 4000,

    browserNoActivityTimeout: 200000
  });
};

我已经尝试过其他浏览器(Firefox、Safari),但我遇到了同样的错误;

使用调试:

    DEBUG [config]: Loading config /karma.conf.js
DEBUG [plugin]: Loading karma-* from /Users/julivan/Dev/workspace/node_modules
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-ie-launcher.
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-opera-launcher.
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-requirejs.
DEBUG [plugin]: Loading plugin /Users/julivan/Dev/workspace/node_modules/karma-safari-launcher.
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at /var/folders/sj/29rxcs914dzgthjcy1hyhch80000gn/T/karma-45854671
DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/sj/29rxcs914dzgthjcy1hyhch80000gn/T/karma-45854671 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:9876/?id=45854671
DEBUG [watcher]: Resolved files:
    /Users/julivan/Dev/workspace/node_modules/requirejs/require.js
    /Users/julivan/Dev/workspace/node_modules/karma-requirejs/lib/adapter.js
    /Users/julivan/Dev/workspace/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
    /Users/julivan/Dev/workspace/node_modules/karma-jasmine/lib/boot.js
    /Users/julivan/Dev/workspace/node_modules/karma-jasmine/lib/adapter.js
    /test/test-main.js
    /test/fixtures/dropdown.html
    /test/fixtures/tabs.html
    /test/lib/jasmine-jquery.js
    /lib/handlebars.js
    /lib/jquery.js
    /lib/require.js
    /lib/underscore.js
    /src/common-built.js
    /src/common.js
    /src/modules/dropdown/buildHTML.js
    /src/modules/dropdown/config.js
    /src/modules/dropdown/dataAttributes.js
    /src/modules/dropdown/dropdown.js
    /src/modules/dropdown/events.js
    /src/modules/dropdown/template.js
    /src/pages/prodUnico.js
    /test/spec/dropdownSpec.js
DEBUG [watcher]: Watching "/lib"
DEBUG [watcher]: Watching "/src"
DEBUG [watcher]: Watching "/test"
DEBUG [web-server]: serving: /Users/julivan/Dev/workspace/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /Users/julivan/Dev/workspace/node_modules/karma/static/karma.js
DEBUG [web-server]: upgrade /socket.io/1/websocket/xSDp8VIKhoKEIwRmCluU
DEBUG [karma]: A browser has connected on socket xSDp8VIKhoKEIwRmCluU
INFO [Chrome 40.0.2214 (Mac OS X 10.10.1)]: Connected on socket xSDp8VIKhoKEIwRmCluU with id 45854671
DEBUG [launcher]: Chrome (id 45854671) captured in 1.616 secs
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: /Users/julivan/Dev/workspace/node_modules/karma/static/context.html
DEBUG [web-server]: serving (cached): /Users/julivan/Dev/workspace/node_modules/requirejs/require.js
DEBUG [web-server]: serving (cached): /Users/julivan/Dev/workspace/node_modules/karma-requirejs/lib/adapter.js
DEBUG [web-server]: serving (cached): /Users/julivan/Dev/workspace/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
DEBUG [web-server]: serving (cached): /Users/julivan/Dev/workspace/node_modules/karma-jasmine/lib/boot.js
DEBUG [web-server]: serving (cached): /Users/julivan/Dev/workspace/node_modules/karma-jasmine/lib/adapter.js
DEBUG [web-server]: serving (cached): /test/test-main.js
DEBUG [web-server]: serving (cached): /test/spec/dropdownSpec.js
DEBUG [web-server]: serving (cached): /src/modules/dropdown/dropdown.js
DEBUG [web-server]: serving (cached): /src/modules/dropdown/config.js
DEBUG [web-server]: serving (cached): /lib/jquery.js
DEBUG [web-server]: serving (cached): /test/lib/jasmine-jquery.js
DEBUG [web-server]: serving (cached): /src/modules/dropdown/buildHTML.js
DEBUG [web-server]: serving (cached): /src/modules/dropdown/events.js
DEBUG [web-server]: serving (cached): /src/modules/dropdown/dataAttributes.js
DEBUG [web-server]: serving (cached): /src/modules/dropdown/template.js
DEBUG [web-server]: serving (cached): /lib/underscore.js
DEBUG [web-server]: serving (cached): /lib/handlebars.js
Chrome 40.0.2214 (Mac OS X 10.10.1): Executed 0 of 12 SUCCESS (0 secs / 0 secs)
DEBUG [web-server]: serving (cached): /test/fixtures/dropdown.html
INFO [watcher]: Changed file "/src/modules/dropdown/dataAttributes.js".
DEBUG [karma]: List of files has changed, trying to execute
INFO [karma]: Delaying execution, these browsers are not ready: Chrome 40.0.2214 (Mac OS X 10.10.1)

没有下划线,一切都很完美,这对我来说毫无意义。

有什么想法吗?

提前致谢

我加上这个..

captureTimeout: 60000,

问题解决了..

尝试更新您的浏览器。它帮助了我。

sudo apt-get install chromium-browser

sudo apt-get install google-chrome-stable