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

Overwrite .type() command with promise times out #29482

Open
d-v opened this issue May 7, 2024 · 0 comments
Open

Overwrite .type() command with promise times out #29482

d-v opened this issue May 7, 2024 · 0 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this topic: cy.type ⌨️

Comments

@d-v
Copy link

d-v commented May 7, 2024

Current behavior

Getting an error Timed out retrying after 20000ms: Cannot read properties of undefined (reading 'length') when trying to add functionality to .type()

Timed out retrying after 20000ms: Cannot read properties of undefined (reading 'length')
View stack trace
 Print to console
    at retryActionability (https://www.google.com/__cypress/runner/cypress_runner.js:112360:19)
    at tryCatcher (https://www.google.com/__cypress/runner/cypress_runner.js:1807:23)
    at Promise.attempt.Promise.try (https://www.google.com/__cypress/runner/cypress_runner.js:4315:29)
From previous event:
    at Promise.longStackTracesCaptureStackTrace [as _captureStackTrace] (https://www.google.com/__cypress/runner/cypress_runner.js:3486:19)
    at Promise.attempt.Promise.try (https://www.google.com/__cypress/runner/cypress_runner.js:4305:9)
    at whenStable (https://www.google.com/__cypress/runner/cypress_runner.js:144028:68)
    at <unknown> (https://www.google.com/__cypress/runner/cypress_runner.js:143969:14)
    at tryCatcher (https://www.google.com/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (https://www.google.com/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (https://www.google.com/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (https://www.google.com/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (https://www.google.com/__cypress/runner/cypress_runner.js:1701:18)
    at Promise._fulfill (https://www.google.com/__cypress/runner/cypress_runner.js:1645:18)
    at <unknown> (https://www.google.com/__cypress/runner/cypress_runner.js:5450:46)

Desired behavior

Would like to cy.wait() for 0 seconds and then run the original type command.

The code at sample overwriting type() command works but does not include promises
https://docs.cypress.io/api/cypress-api/custom-commands#Overwrite-type-command

Test code to reproduce

const snapshot = (originalFn, subject, text, options) => {
  cy.wait(0).then(() => originalFn(subject,text,options))
}

Cypress.Commands.overwrite(
  'type', snapshot
)

describe('test', () => {
  it('checks sample app', () => {
    cy.visit('https://google.com')
    cy.get("textarea[aria-label='Search']").type('cypress\n')
    cy.contains("results", { matchCase: false })
});

Cypress Version

13.7.0

Node version

20.10.0

Operating System

windows 10 22H2

Debug Logs

No response

Other

No response

@jennifer-shehane jennifer-shehane added topic: cy.type ⌨️ stage: needs investigating Someone from Cypress needs to look at this labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this topic: cy.type ⌨️
Projects
None yet
Development

No branches or pull requests

2 participants