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

feat(upgrade): provide test helpers for wiring up injectors #16848

Closed

Conversation

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented May 17, 2017

Sits on top of #29466

This PR provides two test helpers for the upgrade/static library, which wire up the Angular and AngularJS injectors without the need for a full bootstrap of a hybrid app.

  • createAngularJSTestingModule() should be used in AngularJS tests
  • createAngularTestingModule() should be used in Angular tests

Check out the spec files for example usage.

@mhevery
Copy link
Contributor

@mhevery mhevery commented May 17, 2017

Looking good! I think we need some more documentation on how to use this. Can this be part of the API docs?

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented May 17, 2017

I'll add docs but wanted feedback on whether this is the right API first.

@gkalpak
Copy link
Member

@gkalpak gkalpak commented May 22, 2017

As a reminder, the helpers need to be exported and upgrade/testing should be added to a bunch of lists for it to appear in the docs etc.

@juliemr
Copy link
Member

@juliemr juliemr commented Jun 23, 2017

Ping?

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jun 25, 2017

Sorry I have been distracted. I will tidy it up this week.

@petebacondarwin petebacondarwin self-assigned this Jun 25, 2017
@petebacondarwin petebacondarwin force-pushed the ngupgrade-testing-api branch from c73b392 to 52735ee Jul 3, 2017
@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jul 3, 2017

I have made the suggested changes, where appropriate, added documentation and included this new module in as many configuration files as I could find.

PTAL: @mhevery @juliemr @gkalpak

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jul 3, 2017

And of course this PR falls foul of the change from CircleCI v1 to v2.

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jul 3, 2017

Just checking to see if closing and reopening helps with CircleCI

Copy link
Member

@gkalpak gkalpak left a comment

Just a few nits. Looks great so far (except that I have no idea about all the places we need to list a new package 😁)
I assume more tests will be added when this is finalized.

One thing I am a little concerned with is the namespacing of the module. Typically @angular/foo/testing is for testing @angular/foo/bar. So, I would expect the testing package for @angular/upgrade/static to be @angular/upgrade/static/testing (while @angular/upgrade/testing sounds more about testing @angular/upgrade).
I hope that eventually, @angular/upgrade will get dropped and @angular/upgrade/static will be moved to @angular/upgrade (together with its testing module).

aio/tools/transforms/angular-api-package/index.js Outdated Show resolved Hide resolved
@@ -21,6 +21,7 @@ import * as platformServerTesting from '@angular/platform-server/testing';
import * as router from '@angular/router';
import * as routerTesting from '@angular/router/testing';
import * as upgrade from '@angular/upgrade';
Copy link
Member

@gkalpak gkalpak Jul 5, 2017

Unrelated to this PR: Does this include upgrade/static? Shouldn't it be explicitly imported?

packages/upgrade/testing/src/create_angular_test_module.ts Outdated Show resolved Hide resolved
packages/upgrade/testing/src/create_angular_test_module.ts Outdated Show resolved Hide resolved
@kieranblight
Copy link

@kieranblight kieranblight commented Jul 21, 2017

Hi @petebacondarwin, I am just wondering what the rough timeline for this to be release will be?

@petebacondarwin petebacondarwin force-pushed the ngupgrade-testing-api branch from 0743841 to 0260634 Jul 22, 2017
@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jul 22, 2017

@kieranblight - I have been having difficulties getting the new package into the system. I hope to finish this and get it in by the end of this week.

@kieranblight
Copy link

@kieranblight kieranblight commented Jul 24, 2017

@petebacondarwin thank you, look forward to it :)!

@petebacondarwin petebacondarwin force-pushed the ngupgrade-testing-api branch 3 times, most recently from 0ca84ba to 733d0aa Jul 29, 2017
@petebacondarwin petebacondarwin force-pushed the ngupgrade-testing-api branch 2 times, most recently from d3c0ab5 to 590e8c2 Aug 17, 2017
@petebacondarwin petebacondarwin force-pushed the ngupgrade-testing-api branch from eac230b to 5d53a7e Apr 25, 2019
@zuzusik
Copy link

@zuzusik zuzusik commented Jun 13, 2019

any expectations on when this is going to be finished?

thanks!

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jun 13, 2019

Apart from the conflicts it is ready to be reviewed. It is unlikely to land before 8.2 or 9 now.
I'll rebase tomorrow and chase someone (like @IgorMinar) to take a view.

Adds two new helper functions that can be used when unit testing Angular services
that depend upon upgraded AngularJS services, or vice versa.
The functions return a module (AngularJS or NgModule) that is configured to wire up
the Angular and AngularJS injectors without the need to actually bootstrap a full
hybrid application.

This makes it simpler and faster to unit test services.
packages/examples/upgrade/static/ts/full/module.ts Outdated Show resolved Hide resolved
packages/upgrade/static/testing/BUILD.bazel Outdated Show resolved Hide resolved
packages/upgrade/static/testing/tsconfig-build.json Outdated Show resolved Hide resolved
alxhub
alxhub approved these changes Jun 14, 2019
Copy link
Contributor

@alxhub alxhub left a comment

+1 for compiler.

Copy link
Member

@IgorMinar IgorMinar left a comment

Lgtm for API changes.

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Jun 17, 2019

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Jun 17, 2019

Presubmit indicated that we need to perform additional changes in build files in g3 to land this PR. I've added "cleanup" label for now and will look into the build files update asap. Thank you.

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Jun 18, 2019

Thanks @AndrewKushnir

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Jun 19, 2019

New VE presubmit, including g3 changes.

Note to Caretaker: this PR requires additional change in g3: cl/254085499, to update BUILD file with extra rules to build upgrade/testing package.

@kara kara closed this in 5e53956 Jun 21, 2019
kara added a commit that referenced this issue Jun 21, 2019
)

Adds two new helper functions that can be used when unit testing Angular services
that depend upon upgraded AngularJS services, or vice versa.
The functions return a module (AngularJS or NgModule) that is configured to wire up
the Angular and AngularJS injectors without the need to actually bootstrap a full
hybrid application.

This makes it simpler and faster to unit test services.

PR Close #16848
@samjulien
Copy link
Contributor

@samjulien samjulien commented Aug 20, 2019

For anyone who finds this thread in the future, these helpers are available. Check out the docs here: https://angular.io/api/upgrade/static/testing

@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Sep 20, 2019

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 20, 2019
@petebacondarwin petebacondarwin deleted the ngupgrade-testing-api branch Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.