业力配置禁用无头 chrome 并仅使用终端
karma configuration to disable headless chrome and use only terminal
我正在尝试 运行 Angular 单元测试。我想配置 karma.config 文件不打开无头 chrome。只是我想单独在终端中查看输出。
我尝试在 karma.config...
中的代码行下方进行评论
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
运行ning测试不应该无头打开chrome
您目前没有使用 headless chrome。它正在启动,因为您的设置有 [Chrome]
您需要更改 browser
数组值。
Change browsers: ['Chrome']
to browsers: ['ChromeHeadless']
Full karma.conf.js
file with the ability to run only in terminal
using ChromeHeadless
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false,
customLaunchers:{
HeadlessChrome:{
base: 'ChromeHeadless',
flags: [
'--no-sandbox'
]
}
}
});
};
我正在尝试 运行 Angular 单元测试。我想配置 karma.config 文件不打开无头 chrome。只是我想单独在终端中查看输出。
我尝试在 karma.config...
中的代码行下方进行评论reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
运行ning测试不应该无头打开chrome
您目前没有使用 headless chrome。它正在启动,因为您的设置有 [Chrome]
您需要更改 browser
数组值。
Change
browsers: ['Chrome']
tobrowsers: ['ChromeHeadless']
Full
karma.conf.js
file with the ability to run only in terminal using ChromeHeadless
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false,
customLaunchers:{
HeadlessChrome:{
base: 'ChromeHeadless',
flags: [
'--no-sandbox'
]
}
}
});
};