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(TS): Cypress commands return jQuery objects (#58) #62

Merged
merged 1 commit into from
Jul 19, 2019
Merged

fix(TS): Cypress commands return jQuery objects (#58) #62

merged 1 commit into from
Jul 19, 2019

Conversation

NoriSte
Copy link
Contributor

@NoriSte NoriSte commented Jul 19, 2019

Some functions have not the right typings. I started from the getByLabelText function to discover that the bug affects all the following functions

getByAltText
getByDisplayValue
getByLabelText
getByRole
getBySelectText
getByTestId
getByText
getByTitle

@aaronmcadam (partially) fixed it in #56 but the functions above were left untouched. @aaronmcadam I'm not sure why you have not fixed the above functions too.

Why:
Because you can not consume the getByLabelText etc. functions with the right/expected flow
Screen Shot 2019-07-19 at 13 59 04

How:

To be sure that I'm making the correct thing I proceeded this way:

  • accordingly to the actual typing, the above functions should return standard HTML elements, I've asserted that adding
.then($el => {
   expect(Cypress.dom.isJquery($el)).to.eq(false);
})

to the existing tests.
Screen Shot 2019-07-19 at 13 57 01

  • the tests fail

Screen Shot 2019-07-19 at 13 57 08

  • then, I reverted the assertion and they succeed. I'm now sure that the returned subject is a jQuery instance.

So, I have updated the typings file and I've added one more TS test.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

Fixes #58

Thank you for the amazing library ❤️

@aaronmcadam
Copy link
Collaborator

@NoriSte if I use @ts-ignore on the example used in #58, the test passes. If I inspect the returned value, it is a jQuery element.

@aaronmcadam
Copy link
Collaborator

The missing typings were an oversight, I thought they'd already been typed properly.

@aaronmcadam
Copy link
Collaborator

@kentcdodds I've reviewed the PR and accepted it. Are we good to merge?

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

@kentcdodds kentcdodds merged commit 577290d into testing-library:master Jul 19, 2019
@kentcdodds
Copy link
Member

@all-contributes please add @NoriSte for code

@kentcdodds
Copy link
Member

@all-contributors please add @NoriSte for code and tests

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @NoriSte! 🎉

@NoriSte
Copy link
Contributor Author

NoriSte commented Jul 19, 2019

Thank you for all guys ❤️

@NoriSte NoriSte deleted the pr/fix-ts-all-cypress-commands-return-jquery branch July 19, 2019 15:25
@NoriSte
Copy link
Contributor Author

NoriSte commented Jul 19, 2019

The missing typings were an oversight, I thought they'd already been typed properly.

You made me thought I was missing a key point 😁

@kentcdodds
Copy link
Member

🎉 This PR is included in version 4.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

TypeScript: invoke doesn't see jQuery methods
3 participants