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

fix: cy.then shows wrong type when collection of HTMLElement's is provided #15869

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

badeball
Copy link
Contributor

@badeball badeball commented Apr 8, 2021

User facing changelog

cy.then will show correct type when collection of HTMLElement's is provided.

Additional details

  • Why was this change necessary? => When a collection of HTMLElement's is return from the previous cy.then, it is automatically wrapped with JQuery, but this behavior was not reflected in the function type.
  • What is affected by this change? => N/A
  • Any implementation details to explain? => Added new definition for the function.

Related issues / PRs:

#8440
#14875
#15624

How has the user experience changed?

N/A

PR Tasks

  • Have tests been added/updated?

@badeball badeball requested a review from a team as a code owner April 8, 2021 07:41
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 8, 2021

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2021

CLA assistant check
All committers have signed the CLA.

@jennifer-shehane jennifer-shehane requested review from sainthkh and removed request for a team April 21, 2021 14:49
@jennifer-shehane
Copy link
Member

@sainthkh Any thoughts on needing this extra layer of types for .then?

@bahmutov
Copy link
Contributor

@badeball can you please review our code of conduct here https://github.com/cypress-io/cypress/blob/develop/CODE_OF_CONDUCT.md

@cypress-io cypress-io deleted a comment from badeball Apr 21, 2021
@cypress-io cypress-io deleted a comment from badeball Apr 21, 2021
@cypress-io cypress-io deleted a comment from badeball Apr 21, 2021
@bahmutov
Copy link
Contributor

Dear @badeball if you don't think we (and I personally) eat our own food (which is the right expression, not the offensive version you used several times) by writing a lot of Cypress code, then (pun intended) I don't know what to say. Perhaps taking a break and approaching this problem after a cooling-off period would help you see this problem from our point of view.

Copy link
Contributor

@sainthkh sainthkh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

When cy.then() returns an array of HTMLElements, it wraps it with JQuery. I checked it with the code below:

it('t', () => {
  cy.get('div')
  .then(($div) => {
    $div // $ExpectType JQuery<HTMLDivElement>

    return [$div[0], $div[0]]
  })
  .then(($div) => {
    console.log($div) // => jQuery object.
    $div // $ExpectType JQuery<HTMLDivElement>
  })
})

@jennifer-shehane jennifer-shehane merged commit d4e4885 into cypress-io:develop Apr 22, 2021
tgriesser added a commit that referenced this pull request Apr 26, 2021
* develop: (49 commits)
  fix: `cy.type()` should not change the value attr of button-like inputs. (#16154)
  fix: properly detect `cy.intercept(url, routeMatcher, handler)` overload (#16167)
  fix: consider multiple routes when looking for aliases (#16180)
  fix: pass contextIsolation: true (#16165)
  chore: fix failing "should handle aborted requests" test (#16170)
  feat(issue-3741): added keyboard support for folder (#15648)
  fix(webpack-dev-server): remove hard dependency on html-webpack-plugin v4  (#16108)
  chore(deps): downgrade electron to v12.0.0-beta.14 (#16113)
  fix: accept absolute paths in vite dev server (#16148)
  fix: cy.then shows wrong type when collection of HTMLElement's is provided (#15869)
  fix: do not treat utf8 requests as binary (#15946)
  chore: fix types
  docs: fix broken links for @cypress/react example recipes (#15674)
  update circle yml
  ignore undefined beforeEach
  fix: make vite-dev-server work on windows (#16103)
  chore: add triple slash reference
  chore: remove conflicting types
  chore: rebuild yarn lock
  resolve conflicts in master(fe0b63c) and develop
  ...
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 26, 2021

Released in 7.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants