gpt4 book ai didi

angular cli npm run test with chrome

转载 作者:行者123 更新时间:2023-12-05 07:37:16 24 4
gpt4 key购买 nike

我尝试在 Chrome 中运行 angular cli karma test 以获取本地主机链接。但是如果我运行 npm run test 它会打开 chrome 并立即关闭它。

karma.config.js:

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-junit-reporter'),
require('@angular/cli/plugins/karma')
],
client: {
clearContext: false
},
files: [{
pattern: './src/test.ts',
watched: false
}],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
config: './.angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'junit', 'coverage-istanbul']
: ['progress', 'junit', 'kjhtml'],
junitReporter: {
outputDir: 'test/target',
outputFile: 'surefire-reports/TEST-karma.xml',
suite: '',
useBrowserName: true
},

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: [
//'PhantomJS',
'Chrome'
],
singleRun: true
});
};

如何在 chrome 中运行 npm run test。

我尝试通过我的所有测试获取本地主机,以便我可以在 vs 代码中调试它。

控制台输出:

10% building modules 2/2 modules 0 active10 02 2018 23:45:02.459:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
10 02 2018 23:45:02.462:INFO [launcher]: Launching browser Chrome with unlimited concurrency
10 02 2018 23:45:02.468:INFO [launcher]: Starting browser Chrome 10 02 2018 23:45:12.031:INFO [Chrome 64.0.3282 (Windows 10.0.0)]: Connected on socket QFzL8LOUHJtjA405AAAA with id 83404421
Chrome 64.0.3282 (Windows 10.0.0): Executed 28 of 28 SUCCESS (0.976 secs / 0.951 secs)

最佳答案

如果你的问题是这个=>“如果我运行 npm run test 它打开 chrome 并立即关闭它”那是因为这个=> singleRun=true当它为真时,Karma 捕获浏览器,运行测试并退出。所以把它改成

单次运行:假

关于angular cli npm run test with chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48726300/

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