Skip to content

Why is cy.should() doc uses examples with magic strings instead of using typed function expect expressions? #5737

@LazaroOnline

Description

@LazaroOnline

Subject

API Commands should

Description

In cypress documentation, particularly in the should command docs it shows many examples using "magic strings" like this .should('be.visible')
instead of using typed functions like .should($el => expect($el).to.be.visible()).

If it is for having a shorter method maybe we could have something like this: .expect((to) => to.be.visible()) and keep the typing, but it is still not as short as the original string version.
The problem with strings is that you don't know during build with typescript if the assertion is correct, and during development there are no automatic suggestions for strings.

If there was already a typed way of doing assertions that is closer to the subjacent Chai framework, why did Cypress created the other methods using strings? just because it takes some less characters to write?
Or is there any benefit using the magic string variant or are they exactly the same?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions