Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.then() timed out after waiting 4000ms. Your callback function returned a promise that never resolved. on some tests using axe-core 4.7.1. #160

Open
todd-m-kemp opened this issue May 18, 2023 · 11 comments

Comments

@todd-m-kemp
Copy link

I'm trying to upgrade axe-core to version 4.7.1 but I'm finding that some of my Cypress a11y tests are now unexpectedly failing with this error:

cy.then() timed out after waiting 4000ms.

Your callback function returned a promise that never resolved.

The callback function was:

function (win) {
        if (isEmptyObjectorNull(context)) {
            context = undefined;
        }
        if (isEmptyObjectorNull(options)) {
            options = undefined;
        }
        if (isEmptyObjectorNull(violationCallback)) {
            violationCallback = undefined;
        }
        var _a = options || {}, includedImpacts = _a.includedImpacts, interval = _a.interval, retries = _a.retries, axeOptions = __rest(_a, ["includedImpacts", "interval", "retries"]);
        var remainingRetries = retries || 0;
        function runAxeCheck() {
            return win.axe
                .run(context || win.document, axeOptions)
                .then(function (_a) {
                var violations = _a.violations;
                var results = summarizeResults(includedImpacts, violations);
                if (results.length > 0 && remainingRetries > 0) {
                    remainingRetries--;
                    return new Promise(function (resolve) {
                        setTimeout(resolve, interval || 1000);
                    }).then(runAxeCheck);
                }
                else {
                    return results;
                }
            });
        }
        return runAxeCheck();
    }

It seems that the checks that axe-core is doing now takes longer than 4 seconds which causes then to timeout.

It looks like a workaround is to change the value of Cypress' defaultCommandTimeout but having to change this suite-wide or on a case-by-case basis for impacted tests is not a practical solution.

Another option could be to use the timeout option for uses of then in checkA11y but hardcoding it probably isn't a great idea and how long the timeout should be would also be unclear. 🤔

@MattTreichelYeah
Copy link

MattTreichelYeah commented May 26, 2023

I only see this behaviour when the scan finds something wrong so far - I corrected an obvious issue on a new page and this error went away. I'm not sure what versioning is causing the difference in behaviour because we've recently done some upgrades to major dependencies across the board. We've been on the latest version of cypress-axe for awhile but we're now on Cypress v12.11.

@todd-m-kemp
Copy link
Author

I'm unable to find an issue within the page that's being scanned when we run into this problem. When I scan the page with the axe DevTools Chrome extension (axe-core version 4.7.1) no issues are identified. But, when I use cypress-axe with axe-core version 4.7.1 I get this time out error.

We're using Cypress 12.8.1 in Chrome 113 and cypress-axe 1.4.0, running on macOS 13.3.1 (a). We are trying to upgrade from axe-core version 4.4.2 (where we are not experiencing this problem) to version 4.7.1.

@frodehansen2
Copy link

Any updates on this?

@martinfer-newsuk
Copy link

@frodehansen2 @todd-m-kemp were you able to solve this? I've been running into this same issue 😞

@todd-m-kemp
Copy link
Author

@martinfer-newsuk Sadly, I have not been able to solve this.

@martinfer-newsuk
Copy link

@todd-m-kemp guess I'll increase the defaultCommandTimeout on the test to avoid the error. Thanks for the response 🙏

@frodehansen2
Copy link

frodehansen2 commented Aug 15, 2023

@martinfer-newsuk It just started working on the project where I had the issue. Now i have the same issue on another project, so I guess i just have to wait until it resolves it self again :)

@frodehansen2
Copy link

I just discovered that there are some scenarios this error occurs. Specifically a test where i waited for a named intercept. If i moved the cy.checkA11y() to the next test (which had the same rendered html), everything was fine. Just a tip.

@martinfer-newsuk
Copy link

Thanks for the replies @frodehansen2 and @todd-m-kemp. The workaround of increasing the defaultCommandTimeout solved the errors we were having

@todd-m-kemp
Copy link
Author

Thanks for the replies @frodehansen2 and @todd-m-kemp. The workaround of increasing the defaultCommandTimeout solved the errors we were having

That's good to hear! I just don't want to take that approach in our projects. 😂 Patiently awaiting a proper resolution here...

@marcovdbunt
Copy link

I have the same issue on a page where a webshop-chat is implemented. When chat element is disabled the test is working fine. workaround of increasing the defaultCommandTimeout doesnot solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants