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

"No provider for $scope!" error when testing an ng2 component using an ng1 component #8523

Closed
yjaaidi opened this Issue May 7, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@yjaaidi
Contributor

yjaaidi commented May 7, 2016

Hi!

I'm trying to unit-test an ng2 component which is using an ng1 component.
When using the "TestComponentBuilder", I'm getting the "No provider for $scope!" error while the app has been bootstrapped using ng1.

I can unit-test "manually" using something like this "playgroundElement.innerHTML = '';" but there's no way to use "TestComponentBuilder" which sounds more 2016 for me :)

As you can see on this plunker https://plnkr.co/edit/emNmG6?p=preview

The test works when you set the "ng1Style" var to true (using manual ng1 element injection) at "src/main.ts:63" but setting it to false will fail as it will use "TestComponentBuilder".

Do we absolutely have to downgrade ng2 components using ng1 components in order to test them?

Does this mean that once I'll get rid of ng1 components I will have to rewrite all my tests using "TestComponentBuilder".

Thank you guys!

@wesleycho

This comment has been minimized.

Contributor

wesleycho commented Sep 2, 2016

This can probably be closed since TestComponentBuilder no longer exists in rc6.

@gkalpak

This comment has been minimized.

Member

gkalpak commented Dec 15, 2017

I am going to close this as "won't fix", since the dynamic version of ngUpgrade has been deprecated and this issue refers to a quite old Angular version anyway.

We are also working on some test helpers for the static version of ngUpgrade (e.g. #16848), which should make testing easier (and more idiomatic) in the future.

@gkalpak gkalpak closed this Dec 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment