cypress icon indicating copy to clipboard operation
cypress copied to clipboard

feat: Create public `Cypress.ensure` API for use with custom queries

Open BlueWinds opened this issue 1 year ago • 2 comments

User facing changelog

Creates and adds types to Cypress.ensure API, which can be useful for creating custom queries. This new API is based off the previously undocumented cy.ensure* methods, which are now removed.

In addition, adds public types to cy.now(), which is again useful for custom queries.

Additional details

All the methods on Cypress.ensure are pre-existing, and were already on cy. This PR updates the arguments slightly for consistency, moves many of them to Cypress, and and adds publicly-facing types. Those that didn't end up on Cypress.ensure are split up around the codebase near where they're used.

These are referenced in the Custom Query documentation, which is "why this, why now." https://github.com/cypress-io/cypress-documentation/pull/4835

Steps to test

Type tests have been added. All these commands are also used internally.

How has the user experience changed?

No change to the user experience for the vast majority of users. Plugin authors will have to do less TS juggling to get things to work.

PR Tasks

  • [x] Have tests been added/updated?
  • [n/a] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [x] Has a PR for user-facing changes been opened in cypress-documentation? https://github.com/cypress-io/cypress-documentation/pull/4835
  • [x] Have API changes been updated in the type definitions?

BlueWinds avatar Nov 15 '22 19:11 BlueWinds

Thanks for taking the time to open a PR!

cypress-bot[bot] avatar Nov 15 '22 19:11 cypress-bot[bot]



Test summary

21635 0 1716 0Flakiness 3


Run details

Project cypress
Status Passed
Commit c31e4a4a2c
Started Nov 28, 2022 4:27 PM
Ended Nov 28, 2022 4:45 PM
Duration 17:31 💡
OS Linux Debian -
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

specs_list_latest_runs.cy.ts Flakiness
1 App/Cloud Integration - Latest runs and Average duration > when no runs are recorded > shows placeholders for all visible specs
project-setup.cy.ts Flakiness
1 ... > can setup e2e testing for a project selecting JS
cypress-origin-communicator.cy.ts Flakiness
1 Cypress In Cypress Origin Communicator > cy.origin passivity with app interactions > passes upon test reload mid test execution

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

cypress[bot] avatar Nov 15 '22 21:11 cypress[bot]

In regards to documentation, will Cypress.ensure get its own page like Cypress.dom or just the mentions on the custom-queries page?

I was planning to leave it with just the mentions on custom-queries for now. Adding a page documenting it more explicitly can be a post-release task.

BlueWinds avatar Nov 28 '22 20:11 BlueWinds