angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Code Coverage ignores functions like forwardRef in decorator

Open CSchulz opened this issue 3 years ago • 5 comments

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

With Angular 13 we have encountered fat arrow functions like the forward ref in decorators aren't counted in coverage any longer.

@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  templateUrl: './abschluss.component.html',
  providers: [
    {
      provide: DynamicDocumentLoader,
      useExisting: forwardRef(() => AbschlussComponent),
    },
  ],
})
export class AbschlussComponent implements DynamicDocumentLoader, OnInit {

Before Angular 13 we had 100 % code coverage and after updating to Angular 13 it looses the coverage in functions. lines and statements. It seems to be related to the target version, we had to update it to ES2015 in the specific tsconfig.json files.

Angular 12 was still using ES5 because of the issue we found here angular/angular#44781

Angular 13: image

Angular 12: image

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 13.3.9
Node: 16.14.2
Package Manager: npm 8.5.0
OS: win32 x64

Angular: 13.3.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.9
@angular-devkit/build-angular   13.3.9
@angular-devkit/core            13.3.9
@angular-devkit/schematics      13.3.9
@angular/cli                    13.3.9
@schematics/angular             13.3.9
ng-packagr                      13.3.1
rxjs                            7.5.6
typescript                      4.6.4

Anything else?

No response

CSchulz avatar Aug 19 '22 17:08 CSchulz

Hi @alan-agius4 can you assign this to me? would love to take a look at it.

osaf96 avatar Aug 31 '22 04:08 osaf96

@osaf96, feel free to look into this and post any finding here.

alan-agius4 avatar Aug 31 '22 07:08 alan-agius4

@alan-agius4 sure thing

osaf96 avatar Aug 31 '22 09:08 osaf96

It could be possible related to the @babel/core 7.8.9 and 7.8.10+ changes.

Perhaps related https://github.com/babel/babel/issues/14899

CSchulz avatar Sep 01 '22 16:09 CSchulz

It could be possible that this issue is related to a forgotten emitDecoratorMetadata in the tsconfig.spec.json and not related to angular or similar.

CSchulz avatar Sep 21 '22 13:09 CSchulz