CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Healer priorities and steps are not respected

Open lewimuchiri opened this issue 9 months ago • 0 comments

I have two healers defined as follows:

heal.addRecipe('clickAndType', {
  priority: 1,
  steps: [
    'fillField',
    'appendField',
  ],
  fn: async ({ step }) => {
    const locator = step.args[0];
    const text = step.args[1];

    return ({ I }) => {
      console.log("HEALING THE FILL_FIELD FUNCTION " + locator);

      I.click(locator);
      I.wait(1); // to open modal or something
      I.type(text);
    };
  },
});

heal.addRecipe("waitForVisibleThenClick", {
  priority: 1,
  steps: [
    "click"
  ],
  fn: async ({ step }) => {
    const locator = step.args[0];

    return ({ I }) => {
      console.log("HEALING THE CLICK FUNCTION " + locator);

      I.waitForVisible(locator, 8);
      I.click(locator);
    };
  },
});

And then I have a failing step I.click('#mat-mdc-checkbox-1-input'); When I run my tests, I've noticed that the clickAndType recipe is being called instead of the waitForVisibleThenClick recipe yet clickAndType recipe has not been defined for the click step. Same thing happens even when I change the priorities such that waitForVisibleThenClick has a higher priority. Also, when I comment-out the clickAndType recipe, now the waitForVisibleThenClick is called, which indicates that it was formerly not being called because clickAndType was being called. Any hints?

Details

  • CodeceptJS version: 3.6.2
  • NodeJS Version: 20.12.2
  • Operating System: Windows 11
  • Playwright Helper

lewimuchiri avatar May 13 '24 10:05 lewimuchiri