Giter VIP home page Giter VIP logo

Comments (7)

timiyay avatar timiyay commented on August 18, 2024 3

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.

Fryie avatar Fryie commented on August 18, 2024 3

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.

myartsev avatar myartsev commented on August 18, 2024 2

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.

mike-north avatar mike-north commented on August 18, 2024 1

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.

localpcguy avatar localpcguy commented on August 18, 2024 1

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

  1. work without the service being injected by the developer just to make the test work
  2. require the service to be injected by the developer in order to use the mixin (thereby also working in the test)

from ember-resize.

chriskrycho avatar chriskrycho commented on August 18, 2024

I've started seeing this with acceptance tests after upgrading to Ember 2.13.

from ember-resize.

mike-north avatar mike-north commented on August 18, 2024

🎉 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.