-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
moduleForModel doesn't play nicely with application serializer. #165
Comments
Hey @nathanhammond what's the state of play with this. I'm getting that error when implementing an application serlializer test in 2.7.0 😞 |
@oligriffiths It's still an open issue, we've tracked it down to this file, but nobody has investigated how to make it work. Would you be willing to take a swing at it? |
I just bumped into this. I'm now sure if this is the right way, but let me introduce the way I figured. Why fail
How I solved itFor my use case, since I already have a separate model, all I need to do was pass the name of that model. I just patched import { TestModule } from 'ember-test-helpers';
const TestModuleForModelWithName = TestModule.extend({
init: function(modelName, description, callbacks) {
this.modelName = callbacks.modelName || modelName; // CHECK FOR callbacks.modelName FIRST
this._super.call(this, 'model:' + this.modelName, description, callbacks);
this.setupSteps.push(this.setupModel);
},
// ...
}); Since I couldn't use the default import { createModule } from 'ember-qunit/qunit-module';
createModule(TestModuleForModelWithName, 'application', 'Unit | Serializer | application', {
// Specify the other units that are required for this test.
needs: ['serializer:application'],
modelName: 'minute',
}); In generalHowever I can't think of a way to let ember-cli generate a sane test that passes by default, because it can't figure out which model to use when you create an application serializer. Maybe generating the What do you think? |
@jangxyz This is a unique situation and we can likely write one-off code to support it. Is that something that you would be willing to undertake and write a PR for? |
I just had this problem with circumstances similar to what @jangxyz described above.
I solved it by running It seems vaguely wrong to generate an extraneous model but it was a simple fix. |
…erated tests do pass When you generate the application serializer, the tests will fail with error : `Attempting to register an unknown factory: 'model:application'` This has been reported on github : ember-cli/ember-cli#4879 I found the fix in a comment : emberjs/ember-test-helpers#165 (comment) This `hack` feels wrong but seems to be the simplest.
This should be addressed when using the new testing APIs provided by ember-qunit (e.g. Closing.... |
Original report here: ember-cli/ember-cli#4879
/cc @dustinfarris @stefanpenner
The text was updated successfully, but these errors were encountered: