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://ift.tt/2c53FIR
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);
let res ;
return adapter.ajax(url, method, hash);
}
});
Aucun commentaire:
Enregistrer un commentaire