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

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

yjaaidi opened this issue May 7, 2016 · 3 comments


Copy link

@yjaaidi yjaaidi commented May 7, 2016


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

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!

Copy link

@wesleycho wesleycho commented Sep 2, 2016

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

Copy link

@gkalpak 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
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Sep 13, 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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants