gpt4 book ai didi

Angular 单元测试 - 成功构建后启动 Chrome(需要很长时间)

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

在某些构建 Angular 应用程序的机器上,需要超过 2*60 秒(由 Karma 启动的 Chrome 的默认超时时间来捕获内容)。

有没有办法在构建完成后强制 Karma 启动 Chrome?

我的 package.json :

{
"dependencies": {
"@angular/animations": "4.4.4",
"@angular/common": "4.4.4",
"@angular/compiler": "4.4.4",
"@angular/core": "4.4.4",
"@angular/forms": "4.4.4",
"@angular/http": "4.4.4",
"@angular/platform-browser": "4.4.4",
"@angular/platform-browser-dynamic": "4.4.4",
"@angular/platform-server": "4.4.4",
"@angular/router": "4.4.4",
"rxjs": "5.4.3",
"ts-md5": "^1.2.2",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@angular/cli": "1.4.4",
"@angular/compiler-cli": "4.4.4",
"@types/jasmine": "2.5.45",
"@types/node": "~6.0.60",
"jasmine-core": "^2.8.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.1.2",
"protractor-console-plugin": "^0.1.1",
"protractor-jasmine2-screenshot-reporter": "^0.4.1",
"ts-helpers": "1.1.2",
"ts-node": "^3.3.0",
"tslint": "^5.7.0",
"typescript": "2.3.4"
}
}

karma.conf.js :
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')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [{
pattern: './src/test.ts',
watched: false
},
{
pattern: './src/assets/**',
watched: false,
included: false,
nocache: false,
served: true
}
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage ?
['progress', 'coverage-istanbul'] :
['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
autoWatchDelay: 1000,
browsers: ['Chrome'],
singleRun: false
});
};

最佳答案

如果我理解正确:
ng serve --open就是你要找的。

您可以在成功构建后将其链接为 npm startup script ,或在其他工具中,如 gulpgrunt例如。

关于 Angular 单元测试 - 成功构建后启动 Chrome(需要很长时间),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51084888/

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