-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Error when an App is teared down with App.destroy #104
Comments
@soeffing, Well, I think you forgot setup your test with async helper, like this: test('#selectAward assigns an ad to an award', function(assert) {
var done = assert.async();
var self = this;
Ember.run(function(){
var controller = self.subject();
var award = make('award', 'pending');
var ad = make('ad');
TestHelper.handleUpdate(award);
assert.equal(award.get('ad').get('id'), undefined);
controller.send('selectAward', award, ad);
assert.equal(award.get('ad').get('id'), '1');
done();
});
}); Try that and let me know if that works. What is happening is that your save method is called ( in the controller or wherever ) .. and then you finish test and destroy the model ( while its still inflight ) because you forgot to slow down and wait for save to finish ( which is what the done() ) part does. |
You could also clean it up a touch like this ( just for fun ): test('#selectAward assigns an ad to an award', function(assert) {
var done = assert.async();
var self = this;
Ember.run(function(){
var controller = self.subject();
var award = make('award', 'pending');
var ad = make('ad');
TestHelper.handleUpdate(award);
assert.equal(award.get('ad.id'), undefined);
controller.send('selectAward', award, ad);
assert.equal(award.get('ad.id'), ad.id);
done();
});
}); and then alittle more: test('#selectAward assigns an ad to an award', function(assert) {
var done = assert.async();
var self = this;
Ember.run(function(){
var controller = self.subject();
var award = make('award', 'pending');
var ad = make('ad');
TestHelper.handleUpdate(award);
assert.equal(award.get('ad'), undefined);
controller.send('selectAward', award, ad);
assert.equal(award.get('ad'), ad);
done();
});
}); |
@soeffing, did you fall asleep on me? Can you let me know if this fixes it? I will close in a day or two if I don't hear back. |
That fixed the issue. Sorry for replying to late, I got caught up in another project. Thank you very much @danielspaniel ! |
@danielspaniel hello! I have same problem. My component test looks like here:
I see in console: ✘ Promise rejected after #createMultipleChoice: Assertion Failed: You can only unload a record which is not inFlight. |
@OpakAlex .. This is a pretty funny example, because it is a bit of an abuse of component integration tests. Now I am all for doing whacky things, but maybe in this case you could avoid using the handleCreate and pass an action handler into that component: this.render(hbs`{{x-add-question model=model createQuestion=(action "createQuizQuestion")}}`); and the just stub that action to show it was called? seems like a way to avoid this issue, because I not sure how to fix it!!?? Also, not sure how these component tests handle asynchrony, whereas in an acceptance test this might work out better ?? |
Hello I have same problem too. But with ember-mocha `import { describeModule, it } from 'ember-mocha'`
`import { describe } from 'mocha'`
`import { make, mockCreate} from 'ember-data-factory-guy'`
`import startApp from 'site/tests/helpers/start-app'`
describeModule "controller:contact-us", "ContactUsController", {
integration: true
}, ->
beforeEach ->
Ember.run => @app = startApp()
afterEach ->
Ember.run @app, 'destroy'
describe 'action createInquiry', ->
it 'creates a new inquire', (done) ->
Ember.run =>
inquiry = make 'inquiry'
controller = @subject()
controller.set 'model', inquiry
mockCreate('inquiry').returns {id: 1}
controller.send('createInquiry')
expect(controller.get('model.id')).to.eq '1'
done()
ember-data-factory-guy: 2.8.0 |
For component tests I use the wait helper |
use of the wait helper has helped me. tnx |
Hi,
first of all, your library is awesome. I really enjoy it!
However, I have one problem. When I destroy an app after a test, I get this error:
Error: Assertion Failed: You can only unload a record which is not inFlight
Here is my code:
So the test run fine, when I comment the
App.destroy
statement. But when I run it (which I should) I get that error. I think theinFlight
states gets assigned when a record is saved/commited to the backend but the server never responds (not with success nor failure).Am I doing smth wrong or is this a bug?
Thanks
The text was updated successfully, but these errors were encountered: