Open brianshano opened 6 years ago
This is happening to us as well, dropping to 1.14 resolved it
@mazondo what version of ember are you using?
I just bumped into this in my unit tests (works fine in the app).
Essentially I have a component rendering a handful of links using href-to
.
Ember-2.9.1 ember-href-to-1.15.1
Just noticed that @mazondo downgraded ember-href-to-1.14; I'll try that.
So downgrading to ember-href-to-1.14.0 worked for me too. Thanks @mazondo
Errors exist in Ember-2.16.2 as well. Confirmed downgrading to ember-href-to-1.14.0 does get rid of the errors here as well.
I was seeing this on 1.15.x with ember@2.17.1. Looking into this some it looks like the router isn't setup yet, that's why this._routerMicrolib
is undefined.
this._routerMicrolib
is setup in the _initRouterJs
method. My guess is that the router isn't setup in component tests.
Reference: https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/system/router.js#L396
Looking around some more, it looks like the integration test is setting up the router with:
beforeEach() {
getOwner(this).lookup('router:main').setupRouter();
}
@GavinJoyce Is there a way to automatically setup the router without needing to manually add a beforeEach to every integration test?
@GCheung55 Adding this did fix this particular issue but it broke lot's of other tests.
Looks like this call has side-effects that impact other tests.
@panthony I see. My project has a couple of components that use href-to
so setting up the router in a beforeEach
for their respective tests addressed the issue but I didn’t see side effects to other tests.
We’re the side-effect errors you saw consistent?
@GCheung55 Typically I have:
In integration tests:
Source: | Error: Must setup rendering context before attempting to interact with elements.
In route tests:
Error: Assertion Failed: Attempting to inject an unknown injection: 'service:i18n'
If I add service:i18n
in needs
array it will fails eventually with:
Error: Property set failed: object in path "session" could not be found or was destroyed.
Maybe this is due to ember-simple-auth
somehow.
I did not try to fix them really. I do not wish to add something in a test that break another one, setupRouter
do something that lives beyond the test.
+1 just ran into this when using <a href={{href-to foo}}
in integration test, going to downgrade for now
Just in case this data point is helpful... I'm using Ember 3.3.1 and both 1.14.0 and 1.15.1 cause the error.
seems like _router
is undefined in urlFor
which leads to this?
Ember 2.9.0
Running ember test with ember-href-to v1.14.0 is fine. Using v1.15.0 we get some failing integration tests:
The test renders a component that contains a href-to call:
I haven't manage to recreate it in tests on ember-href-to yet