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

Assertions autocompletion / TypeScript definitions for cy and Cypress #856

Closed
pawelgalazka opened this issue Oct 30, 2017 · 9 comments
Closed
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: user experience Improvements needed for UX
Milestone

Comments

@pawelgalazka
Copy link

pawelgalazka commented Oct 30, 2017

  • Cypress Version: 1.0.3

Is this a Feature or Bug?

Feature

Current behavior:

If I want to use should assert, very often I need to look up the documentation https://docs.cypress.io/guides/references/assertions.html to check what's the assert is, what's the string should be. Which consumes additional time when writing asserts. Also some asserts doesn't seems to be clear, like checking text content against regexp.

It's hard to get autocompletion and arguments suggestion from the editor if assert is a string.

Desired behavior:

Would be great to have assert constructs which would help editors/IDE's with autocompletion, especially if TypeScript type definitions could be used.

Current work around which I'm wondering to use for our team, which is not ideal but it works could be:

const be = {
  visible: ['be.visible']
}

const do = {
  have: {
     attr: () => (name, value) => ['have.attr', name, value]
  }
}

cy
  .get('.someElement')
  .should(...be.visible)
  .and(...do.have.attr('content', 'abc'))

Editor will do autocompletion in that case, which speeds up the process of writing asserts.
Would be great to have some solution to it, built-in Cypress, but it would probably require different approach how asserts are made.

Just a proposition. So far, writing asserts is the biggest pain point in Cypress in our team as it too often requires docs look up.

@pawelgalazka pawelgalazka changed the title Assertions autocomplete Assertions autocompletion Oct 30, 2017
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory stage: proposal 💡 No work has been done of this issue type: user experience Improvements needed for UX labels Oct 31, 2017
@bahmutov
Copy link
Contributor

We should bring @types/cypress (and update them) to ship with Cypress NPM module.

https://www.npmjs.com/package/@types/cypress

@bahmutov bahmutov self-assigned this Nov 21, 2017
@bahmutov bahmutov changed the title Assertions autocompletion Assertions autocompletion / TypeScript definitions for cy and Cypress Nov 21, 2017
@pawelgalazka
Copy link
Author

@bahmutov @types/cypress is not everything, even after bringing it it still won't be possible to suggest options for asserts which are written as a string.

brian-mann pushed a commit that referenced this issue Nov 30, 2017
* start including Cypress TypeScript definitions in CLI for #856

* document cy.type and cy.focused

* document cy.document and Loggable

* document cy.window()

* document cy.trigger methods

* document more interfaces

* document Cypress object

* cli: use existing build script for copying typescript definitions
@bahmutov
Copy link
Contributor

bahmutov commented Dec 1, 2017

Agree with you @pawelgalazka - it is just Cypress API, not the assertions, but it is a start.

@bahmutov bahmutov closed this as completed Dec 1, 2017
@bahmutov bahmutov added this to the 1.1.3 milestone Dec 1, 2017
@bahmutov bahmutov added stage: pending release and removed stage: proposal 💡 No work has been done of this issue labels Dec 1, 2017
@brian-mann
Copy link
Member

Released in 1.1.3.

@brian-mann
Copy link
Member

@pawelgalazka this is what you are asking for here: #1059

I'm going to reopen this issue because what you were asking for was not released in 1.1.3 - but it will be released soon!

@brian-mann brian-mann reopened this Dec 12, 2017
@pawelgalazka
Copy link
Author

@brian-mann This is great! Great job guys!

@NicholasBoll
Copy link
Contributor

#1059 has many happy-path autocompletes. I'm also adding some documentation to each chainer override with a short description, example and links to the appropriate chai, sinon-chai or chai-jquery docs. I'll open another PR for that added functionality later.

@brian-mann
Copy link
Member

Fixed by #1059.

@Karolis92
Copy link

Karolis92 commented Jul 16, 2018

@brian-mann our project is really looking into using Cypress for e2e, but we use Intellij (should be similar to WebStorm) and it doesn't seem to autocomplete with method overrides. Maybe I'm doing something wrong?

I found that creating objects like theses work for autocomplete:

const be = {
  visible: 'be.visible',
  false:   'be.false'
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/driver This is due to an issue in the packages/driver directory type: user experience Improvements needed for UX
Projects
None yet
Development

No branches or pull requests

6 participants