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

ownerInjection stopped working in tests in 3.11 #18259

Closed
mydea opened this issue Aug 13, 2019 · 9 comments · Fixed by #18780
Closed

ownerInjection stopped working in tests in 3.11 #18259

mydea opened this issue Aug 13, 2019 · 9 comments · Fixed by #18780

Comments

@mydea
Copy link
Contributor

mydea commented Aug 13, 2019

I have a test, with code like this:

let service = UserSession.extend({
  myProp: []
}).create(this.owner.ownerInjection());

Which was working fine in 3.10. However, it stopped working in 3.11, with this error:

Assertion Failed: An EmberObject based class, (unknown), was not instantiated correctly. You may have either used newinstead of.create(), or not passed arguments to your call to super in the constructor: super(...arguments). If you are trying to use new, consider using native classes without extending from EmberObject.

I am aware that this is not an ideal pattern, and could be better solved by registering the service and looking it up from the owner. But I guess it is still a bug that this just stopped working now?

@mydea mydea changed the title ownerInjection stopped working in 3.11 ownerInjection stopped working in tests in 3.11 Aug 13, 2019
@mydea
Copy link
Contributor Author

mydea commented Aug 13, 2019

Note: It seems to be working fine in application code, only in tests, with this.owner.ownerInjection() it is failing.

@rwjblue
Copy link
Member

rwjblue commented Aug 13, 2019

@mydea - What kind of tests?

@rwjblue
Copy link
Member

rwjblue commented Aug 13, 2019

Can you spin up a demo repo so we can poke at why it might work in app code but not the test?

@mydea
Copy link
Contributor Author

mydea commented Aug 13, 2019

In all kinds of tests - acceptance, integration, unit.

I am on vacation starting today, I can try to put something together next week, if that helps!

Copy link
Member

rwjblue commented Aug 14, 2019

Ya, sounds great! If others run into this in the meantime, please let us know and spin up a demo repo so we can try to figure out whats going on...

@mydea - Hope you have a great vacation!

@mydea
Copy link
Contributor Author

mydea commented Aug 19, 2019

Thanks :) So I tried to reproduce it, but it worked with a new repo. Maybe it is linked to engines (which is where I encountered this)?

Copy link
Member

rwjblue commented Aug 20, 2019

Ya, possibly. I was thinking perhaps it only was an issue when using a custom resolver or something. I think we need to slowly ramp up the repro to figure out where the problem is coming from...

@mydea
Copy link
Contributor Author

mydea commented Aug 22, 2019

Hmm, I also tried a very basic engine reproduction but it also worked there. Not quite sure what is going on. Basically, this.owner.ownerInjection() is returning undefined. I'll try to find time to dig even deeper into this!

@rwjblue
Copy link
Member

rwjblue commented Feb 28, 2020

Fixed by #18780

@rwjblue rwjblue closed this as completed Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants