I have a component which makes use of an imported object.
import MyObj from '<MODULE_LOCATION>'
;
export default Component.extend({ init(){this._super(...args);// some code which make use of the MyObj}});
To test this component I want to stub MyObj so as to have a particular value for it. What is the best way to access the MyObj.
I’d probably make MyObj
a service that can be injected into the component. Then you can stub the service in the component test. Another approach is you register MyObj
with the container and then look it up from the container in the component. Then in your test, register a stub for MyObj
in the container.
Actually there is no way I can make changes in the component. I am suppose to write only the integration test. Are there any other approaches?