Skip to content
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

Setup context fails when using ember-data v4 and a custom resolver #1386

Closed
anehx opened this issue May 9, 2023 · 0 comments · Fixed by #1387
Closed

Setup context fails when using ember-data v4 and a custom resolver #1386

anehx opened this issue May 9, 2023 · 0 comments · Fixed by #1387

Comments

@anehx
Copy link
Contributor

anehx commented May 9, 2023

Hi

I'm having problems with my tests using a custom resolver (because of ember-engines). The setupContainer function of ember-data v4+ removes deprecated compatibitlity code that allows using optionsForType on the application instance instead of the newer registerOptionsForType method:

https://github.com/emberjs/data/blob/7a957ddcf20c334fc6eeaf82cfa4f0dbb7795dfc/packages/-ember-data/addon/setup-container.js#L12-L39

@ember/test-helpers passes a faked registry object to setupContainer when using a custom resolver which does not have registerOptionsForType but only optionsForType. Shouldn't it pass the owner directly as setupContainer expects an application - not the registry?

I was able to fix the tests by passing owner to setupContainer instead of registry || container here:

I'd appreciate someone taking a look at this as my understanding of this addon is not enough for fixing this properly.

Please let me know if I can help in any way.

Thanks!

anehx added a commit to anehx/ember-test-helpers that referenced this issue May 12, 2023
The `setupContainer` function of `ember-data` expects an application
instance to be passed - in this case that is the faked owner object that
we create when using a custom resolver in tests.

This behaviour previously worked because `ember-data` supported the
usage of legacy function `optionsForType` which exists on the `registry`
object. However, they removed that legacy fallback in v4 and replaced it
with `registerOptionsForType` which does not exist on the registry but
only on the owner.

Resolves emberjs#1386
anehx added a commit to anehx/ember-test-helpers that referenced this issue May 12, 2023
The `setupContainer` function of `ember-data` expects an application
instance to be passed - in this case that is the faked owner object that
we create when using a custom resolver in tests.

This behaviour previously worked because `ember-data` supported the
usage of legacy function `optionsForType` which exists on the `registry`
object. However, they removed that legacy fallback in v4 and replaced it
with `registerOptionsForType` which does not exist on the registry but
only on the owner.

Resolves emberjs#1386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant