Wait for DOM change in order to assert completion of a job

This issue has been tracked since 2022-01-27.

Our platform has a job running feature. The different displayed statuses include: Running, Successful, Failed, Canceled, and Error.

Jobs run via playbooks, and runtime length can vary greatly. We often write tests that require Cypress to wait until a job is finished running in order to assert something.

I want to use cy.waitUntil to wait for 'Running' to no longer be displayed in a certain element in order to proceed with the test commands. I have tried many different things. This is my most recent attempt (so far none of my different ways have worked):

const jobStatusValue = 'Successful'
const checkFunction = () =>
  cy.findByCustomId('job-status-value').then((jobStatus) => jobStatus.text === jobStatusValue)

cy.waitUntil(checkFunction, { timeout: 60000 })

  .should((text) => {

Can you please help me figure out a good way to do this? I would so appreciate it!

NoriSte wrote this answer on 2022-01-27

Uhm, you don't need cy.waitUntil for what you described...
I don't know exactly what your findByCustomId does, but staying with pure Cypress, why a simple

cy.get('[data-testid="job-status-value"]').contains('About', { timeout: 60000 })

doesn't work?

Let me know if it works and in the next few days, I'll explain it better 😊

akus062381 wrote this answer on 2022-01-28

@NoriSte I was way overthinking this I suppose! this works, and thank you.

NoriSte wrote this answer on 2022-01-28

You're welcome! 😊

#341 was similar, I should probably add one more section in the main readme.
The point is: Cypress already allows waiting for almost anything, for the rare occasion where it doesn't, cy.waitUntil comes in help.

More Details About Repo
Owner Name NoriSte
Repo Name cypress-wait-until
Full Name NoriSte/cypress-wait-until
Language JavaScript
Created Date 2019-04-27
Updated Date 2023-03-19
Star Count 635
Watcher Count 8
Fork Count 24
Issue Count 3


Issue Title Created Date Updated Date