AJAX Compatability

Kosher has the ability to wait on AJAX requests just as it waits on normal HTTP requests.

This feature is a necessity for testing single-page applications and applications that load data on-demand or heavily use AJAX in other ways.

To take advantage of this kosher feature, you must modify your application to notify kosher of pending or active AJAX requests. Your app will provide a global function that returns true if AJAX requests are pending/active and false, otherwise. This function must be added to the global window object and must be named ajaxPending.

An example of such a function is shown below. This example adds an ‘interceptor’ to the vue-resource API that maintains a list of unique IDs representing any AJAX requests. As requests are made, an ID is created and pushed to the pendingAjaxRequests array. When requests complete, the ID is removed. Finally, the necessary ajaxPending function returns true if there are any IDs in the array.

    window.pendingAjaxRequests = [];
    window.ajaxPending = () => window.pendingAjaxRequests.length > 0;

    Vue.http.interceptor.before = function(request) {
        const requestUkId = request.getUrl() + "#" +;

        // e is a ProgressEvent --
        request.downloadProgress = function(e) {
            if(e.loaded == {
                _.remove(window.pendingAjaxRequests, requestUkId);

Table of contents