monounity / karma-typescript

Simplifying running unit tests with coverage for Typescript projects.
314 stars 109 forks source link

[angular2-transform] Possible to use Ivy (AOT) engine? #492

Open thw0rted opened 3 years ago

thw0rted commented 3 years ago

I've been having some trouble getting DI to work with my Angular application. I've poked around in the debugger and am unsure how to proceed. Most of the information I can find online about Can't resolve all parameters for My{Component/Directive/Pipe/etc}: (?) is older, and it appears to refer specifically to the deprecated JIT template compiler.

It looks like the official ng test CLI integration uses @angular-devkit/build-angular, but that plugin seems to check if it's been launched via the ng CLI and fail if not. Is there another way to use the AOT / "Ivy" template engine with karma-typescript? Have you looked at possibly integrating it yourself?

ETA: the DI problems were due to a missing core-js/reflect import, not sure if AOT would have actually helped. That said, I'd be interested in an answer to the question regardless, and per my comment below it could fix another problem I'm having.

thw0rted commented 3 years ago

I have a follow up to this question. The details are at https://github.com/ngneat/spectator/discussions/481 but the short version is that I think JIT is breaking @ngneat/spectator, which is a helper library for creating test harnesses for Angular components and directives. There's a repro linked from that discussion.

The Spectator maintainer is saying he doesn't know much about karma-typescript and punted to you, but I'm worried this is going to require deep knowledge of Angular JIT/testbed internals, so I'm not sure it's really on you either.