유닛 테스트를 실행하기 위해 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 스크린 샷) 할 수 있습니다. 내 테스트가 통과하는지 또는 다음 단계를 시작하지 않을지 확인하지 마십시오. 나는 카르마 테스트가 끝난 후 커맨드 라인이나 다른 것을 어떻게 멈추게 할 수 있는지 알려주는 데 도움이 필요합니다.
내가 카르마 구성 (: 60000, singleRun : captureTimeout 참)로 만들려고 내 Jenkinsfile에 이전, 아무것도하지만, 내가 문제를 해결
답변을 수락하면됩니다. – godzsa
예, 완료되었습니다.이 옵션을 사용하지 않습니다. –