-
Notifications
You must be signed in to change notification settings - Fork 3
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
Decorator seems to cache resolved service for all future instances, breaking use in tests #17
Comments
@chancancode What do you think about this? I forgot about this and then ran into this same issue again and spent half the day debugging it. 🤦 |
I think if we're going to cache the return value of the getter that it needs to be in a WeakMap keyed by |
Oh hey, sorry I missed this. I would think for now, we can probably get rid of the caching at the decorator level, unless it's proven to be an important optimization, what do you think? |
ember-polaris-service/ember-polaris-service/src/decorator/stage-three.ts
Lines 280 to 284 in b5d0f30
I ran into an issue writing acceptance tests, where I was providing a different mock implementation of a service in each test. The service was injected (using
override
) into a route under test.What I found was that the mock service was successfully injected into the route for the first test, but when the route instance was reconstructed for the second test, the service was still resolving to the one injected by the first test.
Changing the code quoted above to simply
return service(this, name);
resolved the problem.For reference, my route is doing something like this:
And my tests are doing something like this:
The text was updated successfully, but these errors were encountered: