gpt4 book ai didi

angular - 如何在测试执行后设法退出 phantomJS 启动器?

转载 作者:太空狗 更新时间:2023-10-29 18:04:21 28 4
gpt4 key购买 nike

我正在编写 angular 2 应用程序并尝试使用 phantomJS 启动器在 Gitlab CI 上设置测试。在所有测试通过后,确定 phantomJS 启动器将永远保持事件状态(http://i.imgur.com/TD7cLdq.png)。测试成功后如何退出?

这是我的package.json:

{
"name": "kibernum-dnc-client",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test --browsers PhantomJS",
"testd": "ng test --browsers Chrome",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"core-js": "^2.4.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.25.5",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"phantomjs-prebuilt": "^2.1.14",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
}

这是我的karma.conf.js:

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma'),
require('karma-phantomjs-launcher'),
],
phantomJsLauncher: {
exitOnResourceError: true
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome', 'PhantomJS'],
singleRun: true
});
};

执行测试的命令是npm run test

即使使用 singleRun: true 启动器也会永远存在。

这是示例项目:https://github.com/gandra/angular-testing-demo

重现问题的步骤:

git clone https://github.com/gandra/angular-testing-demo
cd angular-testing-demo
npm install
npm run test

预期:测试通过 ok 并退出控制台但这不会发生:(

最佳答案

由于您使用的是 angular-cli,此命令将解决您的需求。

ng test --single-run

ng test --watch=false

关于angular - 如何在测试执行后设法退出 phantomJS 启动器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42030568/

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