fix(compiler): properly compile DI factories when coverage reporting is enabled#37811
fix(compiler): properly compile DI factories when coverage reporting is enabled#37811JoostK wants to merge 2 commits intoangular:masterfrom
Conversation
|
Any news? |
6070724 to
20c4d98
Compare
There was a problem hiding this comment.
Note: this avoids pulling in the Istanbul related canonicalization logic into production logic, with the downside that testing environments need to configure it correctly. This PR does that for TestBed, but other situations are not covered. Should we just pull in the canonicalization logic here instead? That seems a bit simpler, but I'd love some feedback here.
|
Any news on this? |
|
@klemenoslaj I haven't had cycles to work on this due to v12 priorities, but I was planning to pick up on this sometime soon. |
Thanks for a super fast reply @JoostK. |
AFAIK the problem would also occur in ES5, as the code coverage statements cause Angular to consider a constructor as manually written instead of being just a delegated constructor to the base type. A workaround may be to always write the constructor, including all parameters and a |
Interestingly, I just tested with and without es5 setup. Without it fails, with it works fine. 🤔 |
4bfc814 to
c0db81c
Compare
…is enabled When running tests with code coverage using Istanbul, the code is instrumented with coverage reporting statements. These statements are also inserted into synthesized constructors, preventing Angular from properly recognizing them as synthesized constructor. This commit extends the logic to detect synthesized constructors by first canonicalizing the constructor's code, which strips out Istanbul's instrumentation logic. The tests have been extended with an input file that is being instrumented using the `babel-plugin-istanbul` for both ES2015 and ES5 targets, in order to verify that the approach works for real-world usages. Fixes angular#31337
c0db81c to
9cc5fca
Compare
I have revised the PR a bit and replaced the integration test using the CLI with manually instrumenting code using |
petebacondarwin
left a comment
There was a problem hiding this comment.
LGTM - a couple of suggestions.
|
BTW - I assume that |
Indeed, it shouldn't. The |
…orting is enabled
|
Converting back to draft as there may be an alternative fix that would be superior, if it works. |
|
Closing as superseded by #44732. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When running tests with code coverage using Istanbul, the code is
instrumented with coverage reporting statements. These statements are
also inserted into synthesized constructors, preventing Angular from
properly recognizing them as synthesized constructor.
This commit extends the logic to detect synthesized constructors by
first canonicalizing the constructor's code, which strips out Istanbul's
instrumentation logic.
The tests have been extended with an input file that is being
instrumented using the
babel-plugin-istanbulfor both ES2015 and ES5targets, in order to verify that the approach works for real-world
usages.
Fixes #31337