-
Notifications
You must be signed in to change notification settings - Fork 42
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
resizeService not injected in test environment #43
Comments
I think the solution here is to clarify in the README what needs to be done. I'm wary about injecting services into unit tests without the developer being explicit about it |
In this case, we're talking about integration tests, rather than unit tests. For mine, the expected behaviour for component integration tests is that service injection mirrors development/prod. If a service is injected in development/prod, it's injected in test. This matches the behaviour of other service-injecting Ember add-ons. In my case, I had to change my production code to enable test-specific behaviour. I'm already being explicit about the fact I need the The bug is that, even after I register the service with this.register('service:resize', resizeServiceStub);
this.inject.service('resize', { as: 'resizeService' }); ...it's still not available in my tests. |
I could be wrong, but afaik you should always inject services even in your production code. That is, |
My expectation (and I could have the wrong expectation) is that if I don't need to inject the service in my component in order for it to work, and integration test should not then require me to inject it. You end up in a state where your code works, but the tests fail. While updating the documentation could make this easier to debug when a dev comes across it, personally, I think it would be better to either
|
It's been a while since the last update, just wanted to throw out a +1 that this is an issue. Especially in terms of time it took me fiddling around with tests and finally finding this issue on github. For now I'm going to (redundantly) inject the service into production code. |
I've started seeing this with acceptance tests after upgrading to Ember 2.13. |
🎉 This issue has been resolved in version 0.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Versions
ember 2.4.4
ember-resize 0.0.12
Problem
I recently integrated
ember-resize
into a component, which broke my integration tests. The component rendered and behaved as expected during development, but test runs would fail.Even though I stubbed the
resizeService
as per the Ember component testing docs, the tests failed due toresizeService
beingundefined
.It appears that
ember-resize
does not inject the service in the test environment.Example Test:
Workaround
The problem can be fixed by manually-injecting the service into your component, in your app code
This injection is redundant outside of the test environment, but required within it.
The text was updated successfully, but these errors were encountered: