Getting deprecated error, Do not use `. then` in the Ember.Application instance. (using mocha-adapter and ember 1.7)

I recently updated my version of ember from 1.5 to 1.7. Everything works fine, please wait as I run my tests. I am getting this annoying warning message:

DEPRECATION: Do not use `.then` on an instance of Ember.Application.  Please use the `.ready` hook instead.

      

I'm using the mocha adapter, but I don't think it has to do with the adapter anyway, because when I created a simple jsbin using that adapter, I didn't get any messages. This message appears whenever ever in my test I use andThen (function () {....}). The call that raises this warning comes from this function:

    //IN ember.js file 
    function wait(app, value) {
        return Test.promise(function(resolve) {
            // If this is the first async promise, kick off the async test
            if (++countAsync === 1) {
                Test.adapter.asyncStart();
            }

            // Every 10ms, poll for the async thing to have finished
            var watcher = setInterval(function() {
                // 1. If the router is loading, keep polling
                var routerIsLoading = !!app.__container__.lookup('router:main').router.activeTransition;
                if (routerIsLoading) { return; }

                // 2. If there are pending Ajax requests, keep polling
                if (Test.pendingAjaxRequests) { return; }

                // 3. If there are scheduled timers or we are inside of a run loop, keep polling
                if (run.hasScheduledTimers() || run.currentRunLoop) { return; }
                if (Test.waiters && Test.waiters.any(function(waiter) {
                    var context = waiter[0];
                    var callback = waiter[1];
                    return !callback.call(context);
                })) { return; }
                // Stop polling
                clearInterval(watcher);

                // If this is the last async promise, end the async test
                if (--countAsync === 0) {
                    Test.adapter.asyncEnd();
                }

                // Synchronously resolve the promise
                run(null, resolve, value);//THIS CAUSES THE WARNING MESSAGE 
            }, 10);
        });

    }

      

and then ends here, which finally gives a warning:

 //IN ember.js file
 __exports__.inspect = inspect;// The following functions are intentionally minified to keep the functions
    // below Chrome function body size inlining limit of 600 chars.

    function apply(t /* target */, m /* method */, a /* args */) {
        var l = a && a.length;
        if (!a || !l) { return m.call(t); }
        switch (l) {
            case 1:  return m.call(t, a[0]);
            case 2:  return m.call(t, a[0], a[1]);//this is executed with a[0] as a function that seems like a promise 
            case 3:  return m.call(t, a[0], a[1], a[2]);
            case 4:  return m.call(t, a[0], a[1], a[2], a[3]);
            case 5:  return m.call(t, a[0], a[1], a[2], a[3], a[4]);
            default: return m.apply(t, a);
        }
    }

      

the function passed as an argument for case 2 is:

   function (value) {
                if (sealed) { return; }
                sealed = true;
                if (thenable !== value) {
                    resolve(promise, value);
                } else {
                    fulfill(promise, value);
                }
            }

      

Any idea how I avoid getting this warning. thank.

UPDATE:  I think I have found at least one of the reasons for this problem, caused by registerAsyncHelper. We have a helper written as:

Ember.Test.registerAsyncHelper('clickCheckbox', function(app, selector, context) {
    var $el = findWithAssert(selector, context);

    Ember.run($el, 'mousedown');
    Ember.run($el, 'mouseup');
    Ember.run($el, 'click');
    // Workaround for IE8 because programmatically clicking a checkbox
    // does not fire the "change" event
    Ember.run($el, 'change');

    return wait(app);
});

      

so if i don't use this helper the problem seems to go away! Also if I had to do return wait () instead of wait (app) everything works.

+3


source to share





All Articles