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

Assert element NEVER exists ? #3355

Closed
tnrich opened this issue Feb 6, 2019 · 2 comments
Closed

Assert element NEVER exists ? #3355

tnrich opened this issue Feb 6, 2019 · 2 comments

Comments

@tnrich
Copy link
Contributor

tnrich commented Feb 6, 2019

I'm trying to assert that an element doesn't exist on the page.

Normally I'd just do cy.get(myEl).should("not.exist")

In this case however I'm looking for a toast message that leaves the page rather quickly.

cy.get(myToast).should("not.exist")

doesn't work in this case because the test passes either before the toast is on the page, or the toast leaves the page too quickly.

I want to assert that it NEVER shows up, even if very briefly but am struggling to figure out how to make that assertion.. any ideas?

Thanks!

Here's the actual code in my test just to give a more concrete example:

it(`should be able to edit a sequence and re-open it from the library without having the sequence re-save
  `, () => {
    cy.upsert(['sequence', 'id name sequence'], {
      name: 'thomas',
      sequenceFragments: [
        { index: 0, fragment: 'tagagtagagtagagtagagtagagtagag' }
      ]
    }).then(([{ id }]) => {
      cy.visit(`/sequences/${id}`);
    });
//edit the sequence
    cy.get('.veStatusBar').contains(`Length: 30`);
    cy.get('.veRowView')
      .focus()
      .type('g', { force: true });
    cy.get(`[id="sequenceInputBubble"] input`).type('gatgagagag{enter}');
    cy.contains('Sequence Inserted Successfully')
      .closest('.bp3-toast')
      .find('.bp3-icon-cross')
      .click();
    cy.contains('Sequence Saving...')
      .closest('.bp3-toast')
      .find('.bp3-icon-cross')
      .click();
    cy.contains('Sequence Saved')
      .closest('.bp3-toast')
      .find('.bp3-icon-cross')
      .click();
//open the library
    cy.contains('.header-link-text', 'Molecules').click();
    cy.contains('.bp3-menu-item', 'DNA Sequences').click();
    cy.get(`[data-copy-text="thomas"]`).dblclick();
//open the sequence again and assert that the sequence doesn't try to re-save
    cy.contains('Sequence Saved').should("not.be.visible") // I want this to fail if the "Sequence Saved" toast ever pops up. Currently it passes even when the "Sequence Saved" toast does pop up
  });
@cypress-bot cypress-bot bot added the stage: needs information Not enough info to reproduce the issue label Feb 7, 2019
@bahmutov
Copy link
Contributor

bahmutov commented Feb 7, 2019

Can you spy on JavaScript method that opens the modal? It would be a lot more reliable than "catching" flash of the popup in the DOM

@jennifer-shehane
Copy link
Member

This is tricky to test. I think that reviewing our doc on conditional testing may help you think of some strategies for testing this situation though.

I will be closing this since issues in our GitHub repo are reserved for potential bugs or feature requests.

We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.

Alternatively, signing up for any of you paid plans gives you access to our team for support via email. If you would like something higher touch, we also offer screen sharing and workshops with our premium support options.

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

No branches or pull requests

3 participants