I made my first acceptance test with Ember CLI. I use Ember Mirage to mock the server.
test('create file', function(assert){
visit('/login');
fillIn('input[name=username]', 'Joe');
fillIn('input[name=password]', 'foo');
click('button');
andThen(function() {
visit('/projects/files');
});
andThen(function(){
assert.ok(true);
})
});
The test runs successfully, but it hangs, and I am getting the following error
Uncaught (in promise) Error: Called stop() outside of a test context
at Object.stop (http://localhost:4200/assets/test-support.js:2469:10) at Class.asyncStart (http://localhost:4200/assets/vendor.js:49507:13) at asyncStart (http://localhost:4200/assets/vendor.js:41446:44) at Object.async (http://localhost:4200/assets/vendor.js:41460:7) at fulfill (http://localhost:4200/assets/vendor.js:61624:26) at handleMaybeThenable (http://localhost:4200/assets/vendor.js:61584:9) at resolve (http://localhost:4200/assets/vendor.js:61597:7) at sealed (http://localhost:4200/assets/vendor.js:61536:11)
Ajax service
I use an ajax service, which makes calls to custom api endpoints. As you can see it uses the standard JSONAPISerializer. Could be still a problem ? This is an existing app, and there is no easy way to turn off this service, to test without it.
export default Ember.Service.extend({
// http://stackoverflow.com/questions/9705773/non-crud-actions-with-ember-data
call: function(method, type, id, action, hash = null){
var owner = Ember.getOwner(this);
var adapter = owner.lookup('adapter:application');
var url = adapter.buildURL(type, id) + '/' + action;
if (hash) {
hash.data = $.extend({}, hash);
}
return adapter.ajax(url, method, hash);
}
});
EDIT 1
I have changed the test slightly + turned on ENV.APP.LOG_TRANSITIONS_INTERNAL and ENV.APP.LOG_TRANSITIONS to see better whats going on:
$.Velocity.mock = true
var done = assert.async();
visit('/login');
fillIn('input[name=username]', 'Joe');
fillIn('input[name=password]', 'foo');
click('button');
andThen(function() {
visit('/projects/files/new/overview');
setTimeout(function() {
assert.equal( find('.btn-primary').length, 2,"button was found" );
done();
}, 20000);
});
It looks like the login works fine, then
Transition #2: projects.files.new.overview.index: calling deserialize hook ember.debug.js:51061 Transition #2: projects.files.new.overview.index: calling afterModel hook ember.debug.js:51061 Transition #2: Resolved all models on destination route; finalizing transition. ember.debug.js:6520 generated -> controller:projects Object {fullName: "controller:projects"}
tells me, that the transition was ok, and I can see the new page in qunit's container.
sometimes I also receive
Uncaught 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