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

QUnit start and stop not happening for promises within controller actions. #77

Closed
bguiz opened this issue Jul 16, 2014 · 5 comments
Closed

Comments

@bguiz
Copy link

bguiz commented Jul 16, 2014

The section on async example
says that "Under the hood, if you use Ember.RSVP.Promise, ember-qunit will call QUnit's start and stop helpers to stop the test from tearing down and running other tests while your asynchronous code runs. ember-qunit also asserts that the promise gets fulfilled."

This appears to happen in the general case, but not when an Ember.Controller is being tested,
and action is sent to it:

var ctrl = this.subject();
ctrl.send('myAction'); //promises created here do not result in QUnit's start and stop helpers being called.

This can be inferred from an error that occurs in subsequent, unrelated, tests in other test modules, saying "Uncaught Error: Assertion Failed: calling set on destroyed object"

Code example

@rwjblue
Copy link
Member

rwjblue commented Jul 16, 2014

This depends somewhat on the version of Ember you are using. As of 1.6.0 RSVP based promise used in testing avoid the auto-run assertion that has plagued earlier versions.

The specific example that you referenced though is referring to your test returning a promise, nothing more (AFAICT).

@rwjblue
Copy link
Member

rwjblue commented Jul 16, 2014

I am happy to tweak the verbiage of that to make this more clear, but I do not think this is a fundamental problem of this library so I am closing this issue.

@rwjblue rwjblue closed this as completed Jul 16, 2014
@bguiz
Copy link
Author

bguiz commented Jul 16, 2014

I'm using ember-cli 0.0.39 with ember 1.5.1

This depends somewhat on the version of Ember you are using. As of 1.6.0 RSVP based promise used in testing avoid the auto-run assertion that has plagued earlier versions.

If I understand you correctly, if I upgrade to Ember 1.6.0, the tests that I have written in that code example should work? If not, how would I need to modify the test for it to do so - is there a test case perhaps for this library which shows how to test an asynchronous action?

The specific example that you referenced though is referring to your test returning a promise, nothing more (AFAICT).

My test is not returning a promise (no return statement, should always be undefined). It is the subject of the test, an action on the controller, that is returning the promise. Even when I remove the return in the action, and simply use a promise inside of the action, the same error occurs.

@rwjblue
Copy link
Member

rwjblue commented Jul 16, 2014

The async support that ember-qunit comes with (and is referenced in the README) is specifically referring to any promises returned from your test, not that any promises work anywhere and you don't have to worry about it.

@bguiz
Copy link
Author

bguiz commented Jul 16, 2014

Ah, thanks for clearing that up!

So, is it possible to test an asynchronous action on a controller using ember-qunit?

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

No branches or pull requests

2 participants