component-driven / component-driven/cypress-axe

`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.

Open
#160 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
641
Forks
90
Avg merge
6h 8m
Merged PRs (30d)
1

Description

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. 🤔

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/index.ts at the checkA11y call around line 67 and reproduce the timeout with axe-core 4.7.1. Compare the behavior with Cypress's defaultCommandTimeout and the timeout option for then; done means affected accessibility checks complete without suite-wide or per-test timeout changes, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cypress, typescript
Domain
accessibility, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.