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.

Waiting arbitrary time for the checks to work

See original GitHub issue

Related: #22, vercel/next.js#7945

Full repo: here (note: some of the packages there are not yet published, but the test can run without them)

I have a simple test:

import formatAxeLog from "../helpers/formatAxeLog";

describe("Home page", () => {
  beforeEach(() => {
    cy.visit("/");
  });
  it("Has no detectable a11y violations on load", () => {
    cy.injectAxe();
    // cy.wait(500);
    cy.checkA11y(null, null, formatAxeLog);
  });
});

When I run the tests multiple times they sometimes fail (due to vercel/next.js#7945, as they should), sometimes pass. The only “reliable” way is just to wait. Am I doing something wrong, or this is a bug?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:11

github_iconTop GitHub Comments

2reactions
mwmcodecommented, Dec 21, 2020

Can we make it wait the same timeout amount that cypress waits for before failing an assertion?

I’m having the same issue with an Angular app <a href="somwhere">{{ 'some.text' | translate }}</a> translations are fetched so they sometimes take a bit longer to appear

1reaction
eddybrandocommented, Aug 13, 2021

Any possible solutions without cy.wait(1000); ? I want to avoid that workaround.

Instead of wait, you can try and get a DOM element that you know will render once the page is ready for the tests to run.

Given a markup like

<html>
  ...
  <body>
    <main data-test="main-region">
      This loads when the page is ready for testing.
    </main>
  </body>
</html>

you could write a test like this

it('has no detectable a11y violations on load', () => {
  cy.visit('/')
  cy.get('[data-test=main-region]')
  cy.injectAxe()
  cy.checkA11y()
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to wait for element to disappear in cypress?
I would recommend to use Cypress waitUntil command and use something like ... You almost never need to wait for an arbitrary period...
Read more >
wait - Cypress Documentation
wait () 'yields an object containing the HTTP request and response properties of the request. Examples. Time. Wait for an arbitrary period of...
Read more >
Arbitrary wait between 2 task in scheduler. | Blue Prism Product
Hi All,I am looking for option where I can put some arbitrary wait time between 2 task in given scheduler, like between Restart...
Read more >
Entrypoint — docker-stack Documentation - Apache Airflow
In case you try to use different group, the entrypoint exits with error. ... Waiting for connection involves executing airflow db check command, ......
Read more >
Busy waiting - Wikipedia
In computer science and software engineering, busy-waiting, busy-looping or spinning is a technique in which a process repeatedly checks to see if ......
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