gpt4 book ai didi

angular - 使用 karma 在 headless 模式下启动 Firefox

转载 作者:行者123 更新时间:2023-12-03 22:11:10 25 4
gpt4 key购买 nike

我使用 Angular和' karma '。我的 conf 看起来像这样:

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-firefox-launcher')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['FirefoxHeadless'],
customLaunchers: {
'FirefoxHeadless': {
base: 'Firefox',
flags: [
'-headless',
],
}
},
singleRun: true
});
};

但是,当我发出命令时:
ng t

我的 Firefox 浏览器无法启动。在控制台中,我看到消息:
 10% building 2/2 modules 0 active25 01 2019 13:59:40.553:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
25 01 2019 13:59:40.554:INFO [launcher]: Launching browser FirefoxHeadless with unlimited concurrency
25 01 2019 13:59:40.558:INFO [launcher]: Starting browser Firefox 25 01 2019 14:00:40.592:WARN [launcher]: Firefox have not captured in 60000 ms, killing.
25 01 2019 14:00:40.641:INFO [launcher]: Trying to start Firefox again (1/2).
25 01 2019 14:01:40.662:WARN [launcher]: Firefox have not captured in 60000 ms, killing.
25 01 2019 14:01:40.689:INFO [launcher]: Trying to start Firefox again (2/2).
25 01 2019 14:01:42.605:INFO [Firefox 64.0.0 (Ubuntu 0.0.0)]: Connected on socket UQxl3SDMuWplRfbLAAAA with id 53335141
25 01 2019 14:01:52.607:WARN [Firefox 64.0.0 (Ubuntu 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
Firefox 64.0.0 (Ubuntu 0.0.0) ERROR
Disconnected, because no message in 10000 ms.

Firefox 64.0.0 (Ubuntu 0.0.0) ERROR
Disconnected, because no message in 10000 ms.

我的版本:
"karma": "~1.7.1"
"karma-firefox-launcher": "^1.1.0"
"karma-jasmine": "~1.1.1"
Firefox 64.0

我不明白为什么会这样。为什么浏览器不能启动?在 Chrome浏览器没有这样的问题,但我需要的正是 Firefox .

最佳答案

我解决了这个问题。问题是公司代理服务器。我加karma.conf.js :

customLaunchers: {
'FirefoxHeadless': {
base: 'Firefox',
flags: [
'-headless',
],
prefs: {
'network.proxy.type': 0
}
}
},

它奏效了。

关于angular - 使用 karma 在 headless 模式下启动 Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54364034/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com