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

Using await keyword with promisify #16

Open
godomainz opened this issue Dec 6, 2022 · 0 comments
Open

Using await keyword with promisify #16

godomainz opened this issue Dec 6, 2022 · 0 comments

Comments

@godomainz
Copy link

godomainz commented Dec 6, 2022

I just tried to use await with promisify library.
I put my code below.

import promisify from 'cypress-promise';

describe('My First Test', () => {
  it('Does not do much!', async() => {
    const url = "https://rahulshettyacademy.com/seleniumPractise/#/";
    cy.visit(url);
    cy.get(".search-keyword").type("ca");
    cy.wait(2000);
    cy.get(".products").find(".product").should("have.length", 4);
    cy.get(".products").find(".product").each(async($el, index, list) => {
      const element = cy.wrap($el);
      const txtElement = await promisify(element.find(".product-name"));
    });
  })
})

On this line const txtElement = await promisify(element.find(".product-name")); my code gives below error.

`CypressError: cy.each() timed out after waiting 4000ms.

Your callback function returned a promise that never resolved.

The callback function was:

() => {
          const ret = fn.call(ctx, el, index, subject); // if the return value is false then return early

          if (ret === false) {
            endEarly = true;
          }

          return ret;
        }

    at <unknown> (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139277:83)
From previous event:
    at thenFn (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139276:13)
    at yieldItem (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139662:16)
From previous event:
    at Context.each (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139667:62)
    at wrapped (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:157859:19)
From Your Spec Code:
    at eval (webpack:///./cypress/integration/examples/Test1.spec.ts:14:41)
    at step (https://rahulshettyacademy.com/__cypress/tests?p=cypress\integration\examples\Test1.spec.ts:129:23)
    at Object.eval [as next] (https://rahulshettyacademy.com/__cypress/tests?p=cypress\integration\examples\Test1.spec.ts:110:53)
    at eval (https://rahulshettyacademy.com/__cypress/tests?p=cypress\integration\examples\Test1.spec.ts:104:71)
at new Promise (<anonymous>)
    at ./cypress/integration/examples/Test1.spec.ts.__awaiter (https://rahulshettyacademy.com/__cypress/tests?p=cypress\integration\examples\Test1.spec.ts:100:12)
    at Context.eval (webpack:///./cypress/integration/examples/Test1.spec.ts:4:26)`

Cypress Version
11.2.0

cypress-promise version
^1.1.0

Node version
18.12.1

Operating System
Windows 10 Pro - 21H2 - )S Build 19044.2311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant