【问题标题】:Karma Tesing on Virtual Machine虚拟机上的业力测试
【发布时间】:2017-08-01 15:28:15
【问题描述】:

我正在尝试将业力测试作为自动化 TFS 构建的一部分运行。构建会打开一个浏览器窗口,并且无法在构建服务器上无头运行。这种情况下最好的浏览器配置是什么? 谢谢!

package.json 脚本是

"headlessTest":"karma start --browsers ChromeHeadless karma.conf.js"

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma'),
      require('karma-phantomjs-launcher')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

在 TFS 构建中的控制台窗口中输出

[33m01 08 2017 10:03:00.043:WARN [launcher]: [39mChromeHeadless have notcaptured in 60000 ms, killing. [33m01 08 2017 10:03:02.087:WARN [launcher]: [39mChromeHeadless was notkilled in 2000 ms, sending SIGKILL. [33m01 08 2017 10:03:04.208:WARN [launcher]: [39mChromeHeadless was not``killed by SIGKILL in 2000 ms, continuing.

【问题讨论】:

    标签: javascript tfs virtual-machine karma-jasmine headless-browser


    【解决方案1】:

    您可以尝试使用“nosandbox”来处理 chrome。

    在你的 karma project.conf.js 中使用以下配置:

    browsers: ['ChromeNoSandbox'],
        customLaunchers: {
            ChromeNoSandbox: {
                base: 'Chrome',
                flags: ['--no-sandbox']
            }
        }
    

    参考这个 Github 问题:https://github.com/karma-runner/karma-chrome-launcher/issues/73#issuecomment-236597429


    更新:

    Karma 有一个问题:github.com/karma-runner/karma/issues/2652,无论你可以尝试 Karma 和 Chrome 的不同版本组合,有人提到 downgrading to karma 1.5 有效。

    您也可以尝试增加 Timeout 值,例如 600000,然后再试一次。

    【讨论】:

    • 好的,我这样做了,但在 tfs 控制台上仍然出现超时错误INFO [karma]: [39mKarma v1.7.0 server started at http://0.0.0.0:9877/ [launcher]: [39mLaunching browser ChromeNoSandbox with unlimited concurrency INFO [launcher]: [39mStarting browser Chrome [33m02 08 2017 10:25:31.770:WARN [launcher]: [39mChrome have not captured in 60000 ms, killing. WARN [launcher]: [39mChrome was not killed in 2000 ms, sending SIGKILL. :WARN [launcher]: [39mChrome was not killed by SIGKILL in 2000 ms, continuing.
    • @ProfessorMoriarty 似乎 Karma github.com/karma-runner/karma/issues/2652 存在问题,无论您可以尝试 Karma 和 Chrome 的不同版本组合,有人提到 downgrading to karma 1.5 有效
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 2013-05-28
    • 2016-07-06
    • 2019-04-16
    相关资源
    最近更新 更多