Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5814393

Browse files
committed
fix(@angular/build): resolve junit karma reporter output to workspace root
To maintain behavior with the Webpack-based karma unit-testing availablevia `@angular-devkit/build-angular`, the application build system basedkarma testing will now resolve the output directory location of the junitkarma reporter to the same workspace root location. This is only performedif the `junit` reporter is enabled and the reporter's `outputDir` optionis not an absolute path.(cherry picked from commitbec42f7)
1 parent83c820e commit5814393

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

‎packages/angular/build/src/builders/karma/application_builder.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,35 @@ async function initializeApplication(
577577
parsedKarmaConfig.reporters??=[];
578578
parsedKarmaConfig.reporters.push(AngularPolyfillsPlugin.NAME);
579579

580+
// Adjust karma junit reporter outDir location to maintain previous (devkit) behavior
581+
// The base path for the reporter was previously the workspace root.
582+
// To keep the files in the same location, the reporter's output directory is adjusted
583+
// to be relative to the workspace root when using junit.
584+
if(parsedKarmaConfig.reporters?.some((reporter)=>reporter==='junit')){
585+
if('junitReporter'inparsedKarmaConfig){
586+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
587+
constjunitReporterOptions=(parsedKarmaConfigasany)['junitReporter']as{
588+
outputDir?:unknown;
589+
};
590+
if(junitReporterOptions.outputDir==undefined){
591+
junitReporterOptions.outputDir=context.workspaceRoot;
592+
}elseif(
593+
typeofjunitReporterOptions.outputDir==='string'&&
594+
!path.isAbsolute(junitReporterOptions.outputDir)
595+
){
596+
junitReporterOptions.outputDir=path.join(
597+
context.workspaceRoot,
598+
junitReporterOptions.outputDir,
599+
);
600+
}
601+
}else{
602+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
603+
(parsedKarmaConfigasany)['junitReporter']={
604+
outputDir:context.workspaceRoot,
605+
};
606+
}
607+
}
608+
580609
// When using code-coverage, auto-add karma-coverage.
581610
// This was done as part of the karma plugin for webpack.
582611
if(
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import{expectFileMatchToExist,replaceInFile}from'../../utils/fs';
2+
import{installPackage}from'../../utils/packages';
3+
import{silentNg}from'../../utils/process';
4+
5+
constE2E_CUSTOM_LAUNCHER=`
6+
customLaunchers: {
7+
ChromeHeadlessNoSandbox: {
8+
base: 'ChromeHeadless',
9+
flags: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage'],
10+
},
11+
},
12+
restartOnFileChange: true,
13+
`;
14+
15+
exportdefaultasyncfunction(){
16+
awaitinstallPackage('karma-junit-reporter');
17+
awaitsilentNg('generate','config','karma');
18+
19+
awaitreplaceInFile('karma.conf.js','karma-jasmine-html-reporter','karma-junit-reporter');
20+
awaitreplaceInFile('karma.conf.js',`'kjhtml'`,`'junit'`);
21+
22+
awaitreplaceInFile('karma.conf.js',`restartOnFileChange: true`,E2E_CUSTOM_LAUNCHER);
23+
24+
awaitsilentNg('test','--no-watch');
25+
26+
awaitexpectFileMatchToExist('.',/TESTS\-.+\.xml/);
27+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp