Comments (7)
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 resizeService
, as per the Ember testing docs.
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.
from ember-resize.
I could be wrong, but afaik you should always inject services even in your production code. That is, resizeService: Ember.inject.service('resize')
is exactly the way you should do it.
I'd even go so far as to suggest that this addon should not automatically inject itself via an initializer.
from ember-resize.
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.
My intuition is that this should be the default behaviour, ember-resize should not automatically inject itself into every component. I'm fairly new to Ember, but there is something off here; changing production code to enable test specific behaviour.
from ember-resize.
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
from ember-resize.
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
- work without the service being injected by the developer just to make the test work
- require the service to be injected by the developer in order to use the mixin (thereby also working in the test)
from ember-resize.
I've started seeing this with acceptance tests after upgrading to Ember 2.13.
from ember-resize.
🎉 This issue has been resolved in version 0.2.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
from ember-resize.
Related Issues (20)
- Resize handler executing code against destroyed service object HOT 2
- Action required: Greenkeeper could not be activated 🚨
- In application tests - Error: Cannot re-register: 'service:resize', as it has already been resolved HOT 1
- Action required: Greenkeeper could not be activated 🚨
- Action required: Greenkeeper could not be activated 🚨
- Release a new version HOT 6
- Request "adoption"
- Uncaught Error: Could not find module `@ember-decorators/object/computed` imported from `ember-resize/services/resize` HOT 1
- New release HOT 1
- `export =` is not supported by `@babel/plugin-transform-typescript#7.1.0` HOT 2
- Replace travis-deploy-once with Travis-CI stage
- 0.3.1 not published HOT 3
- Does not work with decorators HOT 2
- Removing event listeners on debouncedDidResize removes every listener regardless of context
- Future Usage with Glimmer Components HOT 1
- Upgrade to current ember-cli-typescript
- Ember 3.12, error, remove a not existing function listener
- Deprecation warnings with Ember 3.21
- Dependency Dashboard
- Action Required: Fix Renovate Configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-resize.