Attempting to run acceptance tests in Ember:
test('successful login', (assert) => {
Ember.run(() => {
visit('/signin');
fillIn('#email', '[email protected]');
fillIn('#password', 'password');
click(':submit');
andThen(function() {
assert.equal(currentURL(), '/');
});
});
});
Occasionally (and seemingly randomly) yields the error:
"Global error: Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run..."
I was able to get a working version:
test('successful login', (assert) => {
const done = assert.async();
Ember.run(() => {
visit('/signin').then(() => {
fillIn('#email', '[email protected]').then(() => {
fillIn('#password', 'keen').then(() => {
click(':submit').then(() => {
assert.equal(currentURL(), '/');
done();
});
});
});
});
});
});
However, if I include a second test making use of the same route (for an unsuccessful login), one of them almost always ends up with the error listed above.
I am wondering what I am not understanding about the run-loop, Ember.run, and how to test with async behavior. Any help or pointers towards a good resource would be greatly appreciated!
Ember.run
? That is not needed and likely the cause of your issues. – steveax