question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"AssertionError: 1 accessibility violation was detected: expected 1 to equal 0"?

See original GitHub issue

I’m using cypress-axe to do some accessibility testing, but the errors I’m getting are not clear enough for me to act on… Is there a way to get more detailed information here?

  6 passing (23s)
  22 pending
  2 failing

  1) Accessibility Tests Global Component Assessments Desktop Assessments Petition Petition form should be accessible.:
     AssertionError: 1 accessibility violation was detected: expected 1 to equal 0
      at Function.fn.(anonymous function) [as equal] (http://localhost:8000/__cypress/runner/cypress_runner.js:86181:34)
      at getRet (http://localhost:8000/__cypress/runner/cypress_runner.js:89187:16)
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:139407:23)
      at Function.Promise.attempt.Promise.try (http://localhost:8000/__cypress/runner/cypress_runner.js:136682:29)
      at Context.thenFn (http://localhost:8000/__cypress/runner/cypress_runner.js:89201:23)
      at Context.then (http://localhost:8000/__cypress/runner/cypress_runner.js:89525:21)
      at Context.<anonymous> (http://localhost:8000/__cypress/runner/cypress_runner.js:100860:21)
      at http://localhost:8000/__cypress/runner/cypress_runner.js:100381:33
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:139407:23)
      at Promise._settlePromiseFromHandler (http://localhost:8000/__cypress/runner/cypress_runner.js:137343:31)
      at Promise._settlePromise (http://localhost:8000/__cypress/runner/cypress_runner.js:137400:18)
      at Promise._settlePromiseCtx (http://localhost:8000/__cypress/runner/cypress_runner.js:137437:10)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueue (http://localhost:8000/__cypress/runner/cypress_runner.js:134137:12)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:134142:10)
      at Async.drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:134016:14)

  2) Accessibility Tests Global Component Assessments Desktop Assessments Petition Petition form should be accessible.:
     AssertionError: 1 accessibility violation was detected: expected 1 to equal 0
      at Function.fn.(anonymous function) [as equal] (http://localhost:8000/__cypress/runner/cypress_runner.js:86181:34)
      at getRet (http://localhost:8000/__cypress/runner/cypress_runner.js:89187:16)
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:139407:23)
      at Function.Promise.attempt.Promise.try (http://localhost:8000/__cypress/runner/cypress_runner.js:136682:29)
      at Context.thenFn (http://localhost:8000/__cypress/runner/cypress_runner.js:89201:23)
      at Context.then (http://localhost:8000/__cypress/runner/cypress_runner.js:89525:21)
      at Context.<anonymous> (http://localhost:8000/__cypress/runner/cypress_runner.js:100860:21)
      at http://localhost:8000/__cypress/runner/cypress_runner.js:100381:33
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:139407:23)
      at Promise._settlePromiseFromHandler (http://localhost:8000/__cypress/runner/cypress_runner.js:137343:31)
      at Promise._settlePromise (http://localhost:8000/__cypress/runner/cypress_runner.js:137400:18)
      at Promise._settlePromiseCtx (http://localhost:8000/__cypress/runner/cypress_runner.js:137437:10)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueue (http://localhost:8000/__cypress/runner/cypress_runner.js:134137:12)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:134142:10)
      at Async.drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:134016:14)

The test code is just a checka11y() call:

[...]

      context("Petition", () => {
        before(() => {
          cy.viewport('macbook-13');
          cy.visit(`/campaigns/single-page/`);
          cy.wait(500);
          cy.injectAxe().configureAxe({
            reporter: "v2"
          });
          cy.get(".sign-petition");
        });

        it("Petition content should be accessible.", () => {
          cy.checkA11y(".sign-petition .petition-content"); // passes
        });

        it("Petition form should be accessible.", () => {
          cy.checkA11y(".sign-petition form"); // generates those 2 errorrs
        });

[...]

And I updated cypress’ /plugins/index.js to include the task logging:

module.exports = (on, config) => {
  on("task", {
    log(message) {
      console.log(message);
      return null;
    },
    table(message) {
      console.table(message);
      return null;
    }
  });
};

But I don’t see anything in the console that lets me figure out what is actually failing and how to fix it =S

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
austinezellcommented, Apr 3, 2020

I encountered this same problem recently. I found that the cy.checka11y can take a violations callback and that Cyrpress will output any thrown exception.

cy.checka11y(null, null, violations => { 
  // format violations
  // manually throw violations
})
0reactions
Pomaxcommented, Apr 15, 2020

fair enough

Read more comments on GitHub >

github_iconTop Results From Across the Web

1 accessibility violation was detected: expected 1 to equal 0 ...
I'm using cypress-axe to do some accessibility testing, but the errors I'm getting are not clear enough for me to act on.
Read more >
How to test for accessibility with Cypress - Deque Systems
In this article, we're going to discuss how to: Create test cases in Cypress. Integrate and use axe to check for accessibility violations....
Read more >
Setting up Cypress with axe for accessibility - Tim Deschryver
When Cypress runs, it will throw and log an AssertionError when the page isn't accessible. Just like most of the Cypress errors, it's...
Read more >
Tricks of Cypress: Accessibility Violation Logging
assert 1 accessibility violation was detected: expected 1 to equal 0. Unfortunately there is no more information about it.
Read more >
2d 1 lines bug+junit - Search OpenShift CI
Bug 2033215: Flaky CI: crud/other-routes.spec.ts fails sometimes with an cypress ace/a11y AssertionError: 1 accessibility violation was detected Status: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found