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

Getting the jquery element but not using it #1

Open
DamienCassou opened this issue Aug 2, 2020 · 0 comments
Open

Getting the jquery element but not using it #1

DamienCassou opened this issue Aug 2, 2020 · 0 comments

Comments

@DamienCassou
Copy link

Hi,

first I would like to thank you for the great webinar. I learned quite a bunch of stuff.

I see this code in your project:

 cy.findAllByTestId('article-preview')
    .should('have.length', articles.length)
    .each(($articlePreview, index) => {
      const article: Article = articles[index]

      cy.wrap($articlePreview).within(() => { ... });

I'm wondering why your code gets the jquery element $articlePreview only to wrap it 3 lines after. Wouldn't it be possible to avoid this round trip? In other words, I would expect to write something like this instead:

 cy.findAllByTestId('article-preview')
    .should('have.length', articles.length)
    .each((articlePreview, index) => {
      const article: Article = articles[index]

      articlePreview.within(() => { ... });

In this version, the first argument to the each() callback is a Cypress object which understands within() as opposed to a jquery element that you have to wrap to get to call within().

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

No branches or pull requests

1 participant