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

Question - Does badeball/ cypress-cucumber-preprocessor aupport async/await? #1246

Closed
3 tasks done
rakeshnambiar opened this issue Oct 4, 2024 · 2 comments
Closed
3 tasks done

Comments

@rakeshnambiar
Copy link

rakeshnambiar commented Oct 4, 2024

Current behavior

When I tried the provided example with aync it throw the error

Cucumber preprocessor detected that you returned a native promise from a function handler, this is not supported. Using async / await is generally speaking not supported when using Cypress, period, preprocessor or not.

Desired behavior

I am trying to do something like https://www.youtube.com/watch?v=5faeSbvCJQY because in real world scenarios mostly I will have to write custom functions and ensure the synchronous execution

Test code to reproduce

  1. Clone th example provided in this same repository (link provided above)
  2. Replace the contents in the duckduckgo.js as below
const { When, Then } = require("@badeball/cypress-cucumber-preprocessor");

When("I visit duckduckgo.com", async () => {
  cy.visit("https://duckduckgo.com/");
});

Then("I should see a search bar", async () => {
  cy.get("input[type=text]")
    .should("have.attr", "placeholder")
    .and(
      "match",
      /Search the web without being tracked|Search without being tracked/
    );

  assert.deepEqual({}, {});
});

Versions

  • Cypress version: latest
  • Preprocessor version: latest
  • Node version: v22.2.0

Checklist

@badeball
Copy link
Owner

badeball commented Oct 5, 2024

Using async / await is generally speaking not supported when using Cypress, period, preprocessor or not.

@badeball badeball closed this as completed Oct 5, 2024
@badeball
Copy link
Owner

badeball commented Oct 5, 2024

Regarding cypress-await: #1219 (comment)

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

2 participants