ユニットテストを実行するためにnodeJs、karma、およびxvfbを持つドッカーコンテナを実行するunjenkinsパイプラインを作成しました。 テストは合格し成功しているが、スクリプトでもcaptureTimeoutで停止することはありません:60000とsingleRun:本当の私は実行ユニットテストカルマスクリプトの後のジェンキンスパイプライン
[33m05 04 2017 16:01:54.227:WARN [karma]: [39mNo captured browser, open http://localhost:9876/
[32m05 04 2017 16:01:54.260:INFO [karma]: [39mKarma v1.3.0 server started at http://localhost:9876/
[32m05 04 2017 16:01:54.262:INFO [launcher]: [39mLaunching browser Chrome with unlimited concurrency
[32m05 04 2017 16:01:54.282:INFO [launcher]: [39mStarting browser Chrome
[32m05 04 2017 16:01:59.120:INFO [Chrome 57.0.2987 (Linux 0.0.0)]: [39mConnected on socket /#0Rk4DaJRdDHKCHNvAAAA with id 66659056
Chrome 57.0.2987 (Linux 0.0.0): Executed 0 of 2 SUCCESS (0 secs/0 secs)
[1A[2KChrome 57.0.2987 (Linux 0.0.0): Executed 1 of 2 SUCCESS (0 secs/0.99 secs)
[1A[2KLOG: 'MAIN'
Chrome 57.0.2987 (Linux 0.0.0): Executed 1 of 2 SUCCESS (0 secs/0.99 secs)
[1A[2KChrome 57.0.2987 (Linux 0.0.0): Executed 2 of 2 SUCCESS (0 secs/1.269 secs)
[1A[2KChrome 57.0.2987 (Linux 0.0.0): Executed 2 of 2 SUCCESS (1.319 secs/1.269 secs)
パイプラインの間違っているカルマ構成
に:
def karma = docker.image('trion/ng-cli-karma')
karma.pull()
try {
karma.run(' -u $(id -u) -v ${WORKSPACE}:/app trion/ng-cli-karma ')
karma.inside {
sh 'npm install'
try {
sh('ng test')
}catch(err) {
sh 'echo TEST FAILED'
step([$class: 'JUnitResultArchiver', testResults: 'report/*.xml', healthScaleFactor: 1.0])
throw err
}
sh 'echo DO SOMETHING ELSE AFTER TEST'
}
sh 'ls -al '
} catch(err) {
sh 'echo RUN DOCKER FAILED'
throw err
}
カルマconf:
module.exports = function (config) {
config.set({
mime: { 'text/x-typescript': ['ts','tsx'] },
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma'),
require('karma-junit-reporter')
],
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
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'],
customLaunchers: {
Chrome_without_sandbox: {
base: 'Chrome',
flags: ['--no-sandbox'] // with sandbox it fails under Docker
}
},
junitReporter: {
outputDir: './report', // results will be saved as $outputDir/$browserName.xml
outputFile: 'report.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: '', // suite will become the package name attribute in xml testsuite element
useBrowserName: false, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {} // key value pair of properties to add to the <properties> section of the report
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul', 'junit']
: ['progress', 'junit'],
captureTimeout: 60000,
singleRun: true
});
};
編集:07/04/2017 誰も私を助けないかもしれませんが、私の問題は私が私のジェンキンスパイプラインを実行する際に実行ユニットテストのステップが完了しなかったことです(cfスクリーンショット)。テストが合格したかどうかを確認して、次のステップを開始しないでください。私はカルマテストが終わった後、コマンドラインなどでそれをやめる方法を知っておくのに助けが必要です。
私はカルマの設定(captureTimeout:60000、singleRun:真)でそれをしようが、何も
あなたはあなたの答えを受け入れるdhould、それは働きます! – godzsa
はい、このオプションはありません:( –