Skip to content

Allow to ignore special character sequences for cy.type #4287

@WiseBird

Description

@WiseBird

Current behavior:

cy.type considers everything in {} as modifier sequence. In our app we have embedded code runner. For testing we put there code from fixtures with cy.type. And cy.type throws CypressError: Special character sequence: '{...}' is not recognized when code includes some braced expression.

Desired behavior:

Add option to cy.type to not treat {} as modifier sequence.

Versions

Cypress: 3.2.0

Activity

changed the title [-]Allow to ignore modifier sequences for type[/-] [+]Allow to ignore modifier sequences for cy.type[/+] on May 23, 2019
jennifer-shehane

jennifer-shehane commented on May 23, 2019

@jennifer-shehane
Member

@WiseBird You can type {{} to type the literal { key as shown in the docs, so this should work:

cy.get('input')
  .type('{{}mycommand}')
  .should('have.value', '{mycommand}')

Looks a little bit funky, but we had to choose some character, happened to be {

WiseBird

WiseBird commented on May 24, 2019

@WiseBird
Author

@jennifer-shehane Yes, I can escape them. But as I said we type source code, it can be quite big. You need to go through it and find all lines with both { } and then escape. Replacing all { with {{ wont work as if there is no } cypress will type both characters.

Wouldn't it be much easier to simply say that there is no control sequences?

jennifer-shehane

jennifer-shehane commented on May 24, 2019

@jennifer-shehane
Member

We could probably add an option to type like, 'charSequences: false`. This will be pretty low priority for our team to work on though, since it is possible to achieve what is needed for this to work.

We are always welcome to pull requests.

Code for .type(): https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/actions/type.coffee#L24
Tests for `.type(): https://github.com/cypress-io/cypress/blob/develop/packages/driver/test/cypress/integration/commands/actions/type_spec.coffee#L1143

changed the title [-]Allow to ignore modifier sequences for cy.type[/-] [+]Allow to ignore special character sequences for cy.type[/+] on May 24, 2019
WiseBird

WiseBird commented on May 25, 2019

@WiseBird
Author

Sorry for my stupidity. While looking at tests I got how escaping really works.

43 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerspkg/driverThis is due to an issue in the packages/driver directorytype: enhancementRequested enhancement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @brian-mann@jennifer-shehane@WORMSS@WiseBird@RubenGarcia

      Issue actions

        Allow to ignore special character sequences for cy.type · Issue #4287 · cypress-io/cypress