cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.09k stars 3.19k forks source link

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

Open d-v opened 6 months ago

d-v commented 6 months ago

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

cypress-app-bot commented 1 week ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.