Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ngsummary in unit testing #8007

Closed
wants to merge 2 commits into from

Conversation

Quramy
Copy link
Contributor

@Quramy Quramy commented Oct 11, 2017

It closes #6650 .

It allows ng test --aot.
If --aot option set, transform initTestEnvironment to add the 3rd argument aotSummaries (https://angular.io/api/core/testing/TestBed#initTestEnvironment) like replacing bootstrap method to use .ngfactory

limitation

It works only if angularCompilerPlugin is supported.

create transformer replace initTestEnvironment
@@ -55,6 +55,11 @@ const TestCommand = Command.extend({
Defaults to the karma config file in .angular-cli.json.`
},
{
name: 'aot',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also have to add the same field into TestOptions interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out, I fixed it :)

@Quramy Quramy force-pushed the use-ngsummary-in-unit-testing branch from e022cce to 14015e2 Compare October 11, 2017 16:47
@filipesilva filipesilva self-assigned this Oct 16, 2017
@filipesilva
Copy link
Contributor

@hansl can you check how this fits into the roadmap please?

@filipesilva filipesilva assigned hansl and unassigned filipesilva Oct 16, 2017
@hansl
Copy link
Contributor

hansl commented Oct 16, 2017

After talking to @tbosch, AOT in unit tests is still experimental. We'll wait until it stabilizes before letting this PR in.

@Quramy
Copy link
Contributor Author

Quramy commented Oct 17, 2017

@hansl Thanks for your comment.

Is tbosh currently working on stabilization? If it takes time for that work, I'd like you to consider reviewing and merging.

I implemented this PR's function as opt-in, and it never effect for users who do not use this option.

AOT in unit tests is still experimental.

I also understand it. But I have been using AOT unit-test since release angular/core v4.2.1 and I have never encountered any issues about this. And CLI users can not use AOT unit testing without ng eject and source code transformation by themselves(it's so painful..), also they are hard to report issues about AOT unit-testing.

@danwulff
Copy link

danwulff commented Nov 9, 2017

Any update on this? I'd love to be able to utilize aot unit testing now that aot compile time is much faster in 5.0

@JBoothUA
Copy link

I apologize if this is an inappropriate place to post this, but I've been stuck with AoT and Unit testing..

I see here that unit testing with AoT isn't officially supported, but I'm having a fundamental flaw with my source code.

it seems that JiT is required for unit testing and that requires component's templateurls and styleurls to be absolute.
Also, that AoT is required for our production and that requires component's templateurls and styleurls to be relative to the component.

what is the best practice for templateurls and styleurls if I wish to run AoT and also karma?

@hansl
Copy link
Contributor

hansl commented Feb 22, 2018

Closing this as AOT is experimental in unit tests. We are waiting for official word from the compiler team.

@hansl hansl closed this Feb 22, 2018
@dominique-mueller
Copy link

Any plans on introducing AoT in unit tests? Perhaps with Ivy?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Feature Request) Ability to use AOT in unit testing
9 participants